DHCP (Dynamic host control protocol) is a networking protocol that is used to automatically assign an ip address to a host. DHCP allows network admins to allocate address ‘pools’ to networks and allow clients with DHCP enabled to automatically acquire their ip address. This has several benefits:

  1. Cuts out manual configuration and therefore saves time (lots of time for a bit network!)
  2. Network changes (for example new DNS server addresses) can be configured by DHCP and therefore dont require manually changing by the admin.
  3. Allows ‘plug and play’ of new clients into the network.

DHCP can not only assign a client an ip address but also many other networking options, the most common being:

  • - Default Gateway
  • - Dns Servers
  • - WINS Servers
  • - Default Domain Name
  • - Static Routes

The DHCP Process – When a computer first initializes its network card and connects up, it will send out a DHCP Discovery packet, this packet gets sent out as a broadcast which means it is destined for all nodes on all networks, because after all, the computer doesnt have an ip address so how does it know where the DHCP server is? Because the packet is a broadcast, all machines on the network will receive it, hopefully a DHCP server will be present and will respond to the request.

All being well a valid DHCP server will respond with a potential lease and will include the ip address and configuration options in the reply. It sends it back to the client using the mac address as the destination (since it still doesnt have an ip address at this point!)

Once the client receives the response it will accept the lease configuration providing that the address is not already in use on the network. It then sends an acknowledgement back to the server to indicate that it is using the lease and all is well, at this point the server will make a note of the lease that is now being used so that it doesnt assign it again to another machine.

At this point the client is now online with a valid ip address and hopefully other options (dns servers, gateway etc) This lease can last between a day and infinity, it is all dependent upon the lease time specified at the DHCP server.

DHCP requests to different networks – A lot of the time a DHCP server will not reside on the same network as some clients may, in this case there is a potential problem, after all, a broadcast (like the DHCP discovery packet) will not be sent across networks by default (routers will simply drop the packet). To overcome this problem your router would need to support an ip-helper command (or something similar) that is able to forward a DHCP broadcast packet onto a host on another network. This essentially turns a broadcast packet into a unicast packet.

Note: A unicast transmission is simply where a single host is sent a packet, as opposed to a broadcast which is where all hosts on a network are sent the packet.

So there you have it, an introduction to DHCP and how it works, please feel free to leave comments below.

Share