I know how to request that a machine to acquire a new IP address, however I've got a slightly different scenario.

I have configured a box locally on my network which has DHCP. Therefore, it acquired an IP address. I want to ship it to somebody on a different network which also has DHCP. Ideally, they would plug in their Ethernet cable before starting up their machine; in reality, they will just plug in cables as fast as they can.

The problem I've seen: they plug in the power first, and then the Ethernet. The machine doesn't automatically acquire an IP address using the new DHCP server unless we have them restart the box (or, if we had them log in, by restarting networking or forcing DHCP to release/renew).

Is there a way to configure an Ubuntu server (10.04 LTS) to automatically try to release/renew any time that an Ethernet cable is connected?

  • 2
    What version of ubuntu ... it should already be doing this as part of the ifup scripts – Zypher Sep 16 '11 at 17:33
  • 10.04 LTS. I can't say for sure that nobody has changed that file. Is there a setting in the ifup scripts that I can look at? – Macho Matt Sep 16 '11 at 17:35
  • FWIW, I'm encountering this same in Ubuntu Server 14.04, pretty much stock installation. – thom_nic Feb 22 '16 at 16:28

It looks like one common way to handle this is to add a udev rules file. I believe this gets installed by some package on a desktop system, but I cannot find it on any of my Ubuntu or Debian servers.

Here is a blog that seems to have some details.

The blog suggests adding a udev rules like this.


# This file causes network devices to be brought up or down as a result
# of hardware being added or removed, including that which isn't ordinarily
# removable.
# See udev(7) for syntax.

SUBSYSTEM=="net", GOTO="net_start"


# Bring devices up and down only if they're marked auto.
# Use start-stop-daemon so we don't wait on dhcp
ACTION=="add",          RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow hotplug $env{INTERFACE}"

ACTION=="remove",       RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow hotplug $env{INTERFACE}"


If you look at the ifup command being used you will notice that it only applies to hotplug interfaces. So be sure to use allow-hotplug instead of auto in your network interfaces file.

  • Interesting, I'm attempting this on an Intel i3 NUC and when I sudo udevadm monitor I don't get any events when plugging or unplugging the ethernet cable. However it looks like simply changing auto eth0 to allow-hotplug eth0 causes a dhcp lease to occur when the ethernet cable is connected. – thom_nic Feb 22 '16 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.