30

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.

5 Answers 5

26

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.

1
  • 4
    The dhcp server at my work uses ARP requests to detect IP conflicts.
    – erichui
    Dec 30, 2010 at 17:40
11

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.

4
  • 1
    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. Dec 30, 2010 at 14:10
  • 1
    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, 2010 at 18:09
  • 1
    Depending on the dhcp server, it can take several seconds regardless of network activity or CPU speed. This is because the server first queries the network to see if an address is in use before it offers it to a client, and it has to wait at least a little while for answers to arrive. This timeout is part of the delay you notice, and it will exist even on the quietest network.
    – ʇsәɹoɈ
    Jun 13, 2019 at 3:37
  • DHCP does decidedly not involve "transactions with all the devices on the network". A broadcast takes exactly the same time as a direct packet, and is not a transacitonj ina ny sense of the word. This answer is grossly wrong. Dec 22, 2023 at 10:09
3

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.

0

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!.

4
  • 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, 2010 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, 2010 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, 2010 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, 2010 at 23:44
0

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.
4
  • It's a home network scenario, I've updated the question. Dec 30, 2010 at 14:14
  • ಠ_ಠ Y U NO ASK SUPERUSER THEN?
    – Matt
    Dec 30, 2010 at 14:17
  • Maybe because it's related to networking and here is the best place for this ?
    – Kedare
    Jan 3, 2011 at 22:30
  • meta.serverfault.com/questions/1049/…
    – Matt
    Jan 6, 2011 at 12:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .