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.

Out of curiosity, why does it often take seconds to obtain network configuration via DHCP when the CPU is capable of processing millions of operations per second and ping to the router takes a couple of milliseconds?

In my home environment with one WiFi router and about 5 devices, it is not rare to see times like 5-10 seconds.

share|improve this question

5 Answers 5

up vote 15 down vote accepted

In addition to the actual acquisition of the DHCP lease from the DHCP server (which typically doesn't take very long), some servers will first ping the IP address it's about to hand out before it actually hands it out to verify that it's not already in use on the network - this takes a few seconds to time out. The client sometimes will do the same (again, to prevent IP address conflicts) which will add some more time. Then, on top of that, some clients will also register their DNS entries etc.

share|improve this answer
1  
The dhcp server at my work uses ARP requests to detect IP conflicts. –  erichui Dec 30 '10 at 17:40

DHCP might take a bit longer time because it involves a series of transactions, not with a single server but with all the devices on the network during the initial request, as it sends a broadcast message.

If you check the RFC for DHCP,

http://www.faqs.org/rfcs/rfc2131.html

you can clearly see the the series of negotiations involves. At the beginning the client sends DHCPDISCOVER to all the devices on the LAN, then the servers running dhcp service return DHCPOFFER message. The client might also wait to get responses from all available dhcp servers before it picks one. Then it sends a DHCPREQUEST with an identifier which indicates which server it has chosen as its ip provider. Finally it gets DHCPACK with all the configuration parameters. This is just a summary of the "3.1 Client-server interaction - allocating a network address" from the RFC.

From my experience dhcp takes long time mainly in large LAN setting with lots of nodes connected. In a homenetwork with just a single dhcp server(WIFI router for instance) and one or two pcs, it is pretty fast.

share|improve this answer
    
In my home network with one WiFi router and about 5 devices, it takes about 5-10 seconds which I consider quite slow. But thanks for the explanation. –  Borek Dec 30 '10 at 14:10
    
make sure you have a single dhcp server. If it is just 5 devices, you might want to reserve IPs to each device in the dhcp server. But if you are curious enough you can use tcpdump to look at the actual negotiation and see what is the causing the delay. –  Daniel t. Dec 30 '10 at 18:09

I don´t know what scenary you have, but in the real world you get the ip address...etc from an old server (dhcp server is always the one with the oldest hardware :) ) with lots of requests, behind a firewall, one or several routers/switches... Latency, cpu power...and in a windows world, dhcp implementation is not as efficient as we would like!.

share|improve this answer
1  
"in a windows world, dhcp implementation is not as efficient as we would like!." Do you have any documentation or sources to back up what you said here? –  mfinni Dec 30 '10 at 14:27
    
No, but for example.... Linux provides fail-over DHCP options in a very easy way. Aside from the builtin Active directory functionality in Windows there´s some other points to consider as potential security problems. –  C_Sense Dec 30 '10 at 15:45
2  
Me thinks that you're regurgitating hyperbole gleaned from years of reading too many internet posts. "Microsoft is bad." "Why?" "Because everyone says so." –  joeqwerty Dec 30 '10 at 16:50
    
You can do overlapping DHCP scopes on Windows DHCP servers. With win2k8 R2, apparently, there's a new failover option as well. Maybe Linux is better than that. None of that has anything to do with "efficiency". And what "security problems" in Windows DHCP are you referring to? I asked you for sources, and instead you throw out more claims. –  mfinni Dec 30 '10 at 23:44

Two reasons (and solutions) I found when I wanted fast replies from my DHCP server.

1) My DHCP did a ping of the address it wanted to allocate. This added 3 seconds delay. I removed this by changing the DHCP config to have a mapping for MAC Address to IP address. This is basically using DHCP to allocate a static address. This removed the 3 second delay for me.

2) I have an isolated network, however, you may get this at times. There was a DNS look up being done, which for me resulted in many seconds delay from getting an IP Address from DHCP. In the DHCP server config there were options for our domain and DNS servers. After removing DNS options and above change I got instant replies from the DHCP server. (**)

These issues were what I found in my setup. Your milage may vary.

cheers

LB

(**) If I had a penny for every time a failed DNS lookup caused a delay which resulted in a strange knock on affect which resulted in me scratching my head, I would have many many pennies.

share|improve this answer

If you are experiencing performance problems with dhcp;

  1. Check network latency
  2. Look at packet cap dhcp negotiation. You should be able to see what action is taking a long time. (problem may not be with the dhcp server, who is waiting on who?)
  3. Examine dhcp server load and logs.
share|improve this answer
    
It's a home network scenario, I've updated the question. –  Borek Dec 30 '10 at 14:14
    
ಠ_ಠ Y U NO ASK SUPERUSER THEN? –  Ablue Dec 30 '10 at 14:17
    
Maybe because it's related to networking and here is the best place for this ? –  Kedare Jan 3 '11 at 22:30
    

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.