Dynamic Host Configuration Protocol. A protocol that a host uses to obtain all necessary configuration information including an IP address. It allows a host to obtain a temporary IP address.

How DHCP works:

  1. When a client computer is started, it broadcasts a message requesting a DHCP server. This request includes the hardware address of the requesting client.

  2. Any DHCP server receiving the broadcast will send out its own broadcast message to the client offering an IP address for a set period of time, known as the lease period.

  3. The client selects one of the offers received. Normally, it looks for the longest lease period.

  4. The client broadcasts that it has selected an offered leased IP address and identifies the selected server.

  5. All non-selected servers return their offered IP addresses back to the pool of available addresses.

  6. The selected DHCP server gives an acknowledgement that includes the IP address, subnet mask, default gateway, DNS server and the lease period. The information broadcast is configurable. (Note from Zorin: a DHCP server's reply to a client is a unicast packet.)

The process is completed, and the client has access to the network. At this point, the user normally logs on.

One thing which I am not particularly happy about is that DHCP offers no such provisioning within the protocol for redundancy. If you have more than one DHCP server hanging out on a given network segment, the client will pick the address offered by whichever server answered the fastest.

At first glance, that sounds okay. However, there currently is not a way to keep the outstanding DHCP leases in sync. As a consequence, you must divide up the assignable range for each DHCP server you have on the same network segment. This solution is sub-optimal, but it is better than managing each address individually.

When setting up your DHCP server, pay attention to the lease time

The client can ask for a long lease, but many clients don't, and simply take whichever lease they're given. Most DHCP servers allow you to set two different lease times - the maximum length of a lease the server will grant, and the length of lease the server offers if the client doesn't request a specific time. It's possible to overlook this and set only the maximum time. In addition, the default lease time is often very short - less than an hour in many cases.

This is A Bad Thing, as it conflicts with power management. Every time the lease expires, the computer will request a new lease, and upon receiving a response will write it to the disk. This leads to the hard disk spinning up and down every time the lease expires, even though the computer is otherwise doing nothing. If the lease time is shorter than the spin-down delay, the drive will never spin down at all. If the hard disk cannot spin down, it will run hotter, and use more power. If the drive has to constantly spin up and down, the spindle motor may wear out earlier than expected.

Long lease times can lead to problems - if enough computers take out a lease, and fail to release it, the server may run out of IP addresses to lease. The longer the lease, the longer the server must wait before it can expire the unrelease lease and hand out the IP address again. However, if a client request a lease, fails to release it and then requests another lease, many servers will release the older lease, meaning that a single client can only ever use one lease. In order to run out of IP addresses on such a server, there would have to be a high turnover of MAC addresses, for instance if there were many laptops coming and going. In a wired network with few roaming laptops, there's nothing wrong with offering leases of a week or longer.

There are 33 million available private IP addresses. Even in a class C address block, there are 254 addresses. If you're administrating a network with more than a hundred machines, you'd better know enough about DHCP that you can ignore this writeup. Unless you're dealing with an enterprise network, or are using public IP addresses, there's no chance you'll run out of IP addresses for the DHCP server to give out. It's far better to reserve more IP addresses than to have hard disks wear out earlier and drive up your energy bills.

Log in or registerto write something here or to contact authors.