Red Hat Bugzilla – Bug 141709
dhcp client takes a long time to fail on boot
Last modified: 2007-11-30 17:10:56 EST
Description of problem:
When I boot my machine without the ethernet cable in, it takes dhcp a
long long time to fail, thus holding up the boot process a couple of
minutes. This seems a bit excessive
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1.use dhcp to make network connection
2.boot without out cable plugged in
takes forever to move on
should give up within a more reasonable time.
The dhcp client (/sbin/dhclient) has a default timeout of 5 minutes,
that is configurable in the file /etc/dhclient.conf (see dhclient.conf
man-page), with the 'timeout' and 'retry' parameters:
timeout: Time between issuing a DHCPDISCOVER and deciding no response
has been received (default: 60 seconds)
retry: Time between attempts to contact the server
(default: 5 minutes)
So for instance you could put this in /etc/dhclient.conf:
' timeout 5;
and dhclient will timeout for 5 seconds twice, giving up after 10
To ensure that, during the DHCPDISCOVER process, timeouts also do not
occur on DNS lookups, put the following line in the file
' /bin/rm -f /etc/resolv.conf
As this problem is correctable with configuration options, and the
defaults are sensible, this issue is not a bug .
If I understand correctly the man page for dhclient.conf, the lines
you gave me:
mean to try for 5 seconds, then wait for 2 seconds and then try again.
In the man page, it doesn't state how many times this process
repeats. Is this the correct interpretation of those lines? Do you
know how many times this repeats?
About dhclient-enter-hooks, this will remove resolv.conf every time I
want to use DHCP. I use a mix of fixed and DHCP IP addresses and I am
wondering how these will work together. In particular, is usually try
to keep the search domain constant no matter where I am. Will I have
to reenter this every time I use DHCP?
Actually, on further consideration I think all you need is a
' timeout 10;
statement in /etc/dhclient.options, since when run from ifup
dhclient is given the '-1' "one-shot" option and will never
retry, so retry is not used.
Setting 'timeout 10' means it will decide that the server is
not contactable after 10 seconds trying.
You don't need to remove the /etc/resolv.conf in
To keep your existing resolv.conf 'search' path after dhclient
gets DNS information from the server, you can either :
- set PEERDNS=no in /etc/sysconfig/network-scripts/ifcfg-$IF
This will disable any DNS information obtained from DNS being
written to resolv.conf, and the existing resolv.conf file will
always be retained.
- You can use the the supersede, prepend and append options in
/etc/dhclient.conf - eg.
' prepend domain-name "mydomain.com ";'
means that 'mydomain.com' will be written to the resolv.conf
'search' path before the search path obtained by DHCP;
' append domain-name " mydomain.com";' will add it to the end
of the dhcp search path in resolv.conf;
' supersede domain-name "mydomain.com";' replaces the dhcp search
path with "mydomain.com" .
These can also be used for the 'domain-name-servers' option to
prepend / append a DNS server address(es) to the DHCP DNS server
list, eg. 'prepend domain-name-servers 127.0.0.1;' .
Thanks for the help and education. It aborts much quicker now.
Yes, this problem has a relatively easy workaround. But the defaults
as shipped aren't sensible, and a suitable /etc/dhclient.conf should
be shipped with the OS to provide sane defaults. Something like 10-15
seconds would be far more reasonable (IIRC, Windows uses 5s).
I woudl reopen this, but apparently I don't have permission to do so...