“Waiting for network configuration…” problem with Ubuntu

WHAT: Running Ubuntu 12.04 LTS “Precise”. After software upgrade, during boot the message displays:

Waiting for network configuration…

After an inordinate amount of time a new message appears:

Waiting up to 60 more seconds for network configuration…

After the system is finished booting and the user logs in, there is no network.

WHY: Unknown.  Apparently however, based upon extensive researching of this problem online, not many people know, including Ubuntu themselves.  Forums are filled with basically useless information about purported fixes which don’t work.  Many seem just lost.

HOW: After logging in I found out that the network can be fixed by simply running the command:

sudo /etc/init.d/network-manager restart

from a console window.  So the solution – admittedly a temporary fix – suggested itself to find a way to simply run this command at login.

WHERE: Ok the question word meme thing is getting stretched at this point, but here’s how I managed to workaround the networking bug:

WHAT: Create a script in the user’s $HOME/bin directory which runs the command and have it automatically run at login.

HOW: First make the $HOME/bin directory if it doesn’t exist:

mkdir ~/bin

Then create the script with a text editor.  I chose to install vim and use it:

vi ~/bin/fixnet

The contents of which should be:

#!/bin/sh
sudo /etc/init.d/network-manager restart

Now make sure the script is executable:

chmod +x ~/bin/fixnet

AND THEN: The issue now is that if we try to have this script automatically run at login as our user, sudo will require a password and the script will not run.  We need therefore to allow this one particular command to execute without a password via sudo.

Edit the sudoers file:

sudo visudo

At the very end of the file add a line like the following:

user      ALL=(ALL) NOPASSWD: /etc/init.d/network-manager restart

Replace user with your username.  The line has to be at the end, or at least after a line which grants permissions to those in the sudo group because entries at the bottom of the file overrule those above.  The sudo line will basically revoke the NOPASSWD directive of the above line if it comes after it.

FINALLY: Now you can test if it all works.  Open a brand new terminal (important!) and type fixnet and see if it runs without asking for a password.

If it does then all is good.  Now you can click on the little gear icon at the very upper right of the screen and choose “Startup Applications…“.  There you can select the script you just created and set it to run automatically at login.

NOTE: This will not fix the stupid “Waiting for network configuration…” bootup delay, but it will ensure that once logged in the network will be up.

PHILOSOPHY: Why didn’t I use the preferred /sbin/initctrl restart method instead of deprecated /etc/init.d/network-manager restart?  Because for some reason I was getting an error with the former method.

Why didn’t I put the script in rc.local to run?  Good question.  I did actually try editing the runlevel rc.2 to have network-manager run.  In fact, since some time ago, I don’t know wtf is going on with the Ubuntu boot process.  network-manager (and a slew of other things) are not even set to run by default in runlevel 2 and are apparently being invoked some other way.  Since I know running the init.d network-manager script from a console after the user logs in works, I decided to just stick with it.