I have a server running Ubuntu 11.04, deployed in the field. When someone is debugging the server, they plug eth1 in, but the rest of the time, nothing is plugged into eth1. The syslog is full of DHCPDISCOVER
requests from dhclient
trying to find a connection. Is there any way I can configure dhclient
to only run DHCPDISCOVER
a fixed number of times?
Syslog entries every:
Nov 2 07:58:32 sensor-2bb8 dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 3
Nov 2 07:58:35 sensor-2bb8 dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 4
Nov 2 07:58:39 sensor-2bb8 dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 8
Nov 2 07:58:47 sensor-2bb8 dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 15
Nov 2 07:59:02 sensor-2bb8 dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 13
Nov 2 07:59:15 sensor-2bb8 dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 14
Nov 2 07:59:29 sensor-2bb8 dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 4
Nov 2 07:59:33 sensor-2bb8 dhclient: No DHCPOFFERS received.
Nov 2 07:59:33 sensor-2bb8 dhclient: No working leases in persistent database - sleeping.
Contents of /etc/network/interfaces
:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth1
iface eth1 inet dhcp
If the device supports hotplug events why not use
allow-hotplug eth1
instead ofauto eth1
. This should mean that the defaults will only try to enable itself if there is actually a link available. Theauto
setting means that the interface will be brought up no matter what the status of the interface is.Have a look at the Debian manual that explains these parameters.
In my opinion tweaking dhclient is not good idea(it can brought you to problems obtaining adresses in future).
You should better turn off the interface and turn on when needed(interface eth1 down/up).
There is a linux daemon called ifplugd that can automatically turn on and configure interface when you plug the cable and turn of interface when unplugged.
There are several options for this case: http://linux.die.net/man/5/dhclient.conf