Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
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

1 Answer 1

up vote 0 down vote accepted

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.

/etc/udev/rules.d/85-ifupdown.rules

# 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"
GOTO="net_end"

LABEL="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}"

LABEL="net_end"

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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