Bug 141709

Summary: dhcp client takes a long time to fail on boot
Product: [Fedora] Fedora Reporter: David Kaplan <dmkaplan>
Component: dhcpAssignee: Jason Vas Dias <jvdias>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-12-03 15:00:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Kaplan 2004-12-03 02:26:01 UTC
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):
dhclient-3.0.1-11

How reproducible:
always

Steps to Reproduce:
1.use dhcp to make network connection
2.boot without out cable plugged in
3.wait...
  
Actual results:
takes forever to move on

Expected results:
should give up within a more reasonable time.

Additional info:

Comment 1 Jason Vas Dias 2004-12-03 15:00:03 UTC
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;
   retry   2;
' 
and dhclient will timeout for 5 seconds twice, giving up after 10
seconds.
To ensure that, during the DHCPDISCOVER process, timeouts also do not
occur on DNS lookups, put the following line in the file
/etc/dhclient-enter-hooks  :
'  /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 . 

Comment 2 David Kaplan 2004-12-03 19:46:37 UTC
If I understand correctly the man page for dhclient.conf, the lines
you gave me:

timeout 5;
retry 2;

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?


Comment 3 Jason Vas Dias 2004-12-03 22:59:30 UTC
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
/etc/dhclient-enter-hooks .

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;
  and 
  '  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;' .
 


Comment 4 David Kaplan 2004-12-04 01:33:24 UTC
Thanks for the help and education.  It aborts much quicker now.

Comment 5 Tethys 2004-12-13 01:55:15 UTC
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...