Our Networking Story

Soren Hansen soren at ubuntu.com
Sat Mar 8 04:27:04 UTC 2014

Sorry for sending this to you twice, Bryan, but my first attempt is stuck in
the moderation queue.

2014-03-07 1:18 GMT+05:30 Bryan Quigley <bryan.quigley at canonical.com>:
> *Network Restart*

> I'd like to start by asking each of you what you think is the correct
> way to restart networking on Ubuntu server?  Feel free to write it
> down and include it in any replies :).

Depends on why you're restarting the network.

If I've just changed an IP address, I'd probably do an "ifdown $IFACE;
ifup $IFACE" in screen or something. If the changes are more involved
than that, you need to be careful. One scenario I've seen countless
times is this:

1. Install Ubuntu Server on a network with DHCP.
2. Log in afterwards to switch to static IP's.
3. Change /etc/network/interfaces to have the static config.
4. "Restart networking" (using whichever of the methods you give as
5. Verify that their static address is correctly assigned.
6. Come back an hour later and see that it's now using DHCP again.
7. Come to #ubuntu-server and complain.

What most people fail to realise (or consider) is that ifdown reads the
*current* configuration to see what to do. So when you've booted with
DHCP (and thus have a dhcp client running in the background), change
/etc/network/interfaces and run ifdown (directly or by way of
/etc/init.d/networking or whatever), ifdown has no clue that there's a
dhcp client that it needs to worry about. It just deconfigures that
interfaces as it would have any other statically configured interface,
because that's what /etc/network/interfaces says it should do.

When it's ifup'ed again, it gets the right address assigned, but the
dhcp client is still running in the background, waiting to screw up your
network config once the lease is about to expire.

This is a common example, but the same issue applies when you're
adding/removing up/pre-up/down/post-down commands. People usually
remember to make sure that anything you establish during up (or pre-up)
you also tear down in down (or post-down), but if you add or remove
things, you need to remember this caveat when "restarting networking".

Depending on how helpful I feel when people ask this on #ubuntu-server,
I either explain this or just tell them to reboot. *shrug*

Soren Hansen
Ubuntu Developer    http://www.ubuntu.com/
OpenStack Developer http://www.openstack.org/

More information about the Ubuntu-devel-discuss mailing list