DHCP Operations
DHCP simplifies network administrative tasks by automatically assigning IP information to hosts on a network. This information can include IP addresses, subnet masks, and default gateways, and is usually assigned when the host boots up.
When the host first boots up, if it has been configured to use DHCP (which most hosts are), it will send a Broadcast message asking for IP information to be allocated. The Broadcast will be heard by the DHCP server and the information will be relayed.
Farai says – “This is assuming that they are on the same subnet. If they are not, then see the ip helper-address command below.”
Figure 14.1 – Host Requests IP Configuration Information
DHCP actually uses UDP ports 67 and 68 to communicate over the network, and, of course, actual servers are usually used as DHCP servers, although routers can also perform this role, if required. Routers can also be configured to obtain their IP address from a DHCP server, if required, although this is rarely done. The command to configure this is:
Router(config-if)#ip address dhcp
DHCP states for clients are as follows:
- Initialising
- Selecting
- Requesting
- Bound
- Renewing
- Rebinding
DHCP servers can be configured to give an IP address to a host for a specified period called the lease time. This can be for hours or days. You can and should reserve IP addresses which cannot be allocated to hosts on the network. These IP addresses will already be in use on router interfaces or for servers. If you fail to do this, you may see duplicate IP address warnings on your network because the DHCP server has allocated your address to a host.
The full DHCP request and assign process can be seen in Figure 14.2 below:
Figure 14.2 – DHCP Request and Allocation Process
- 1. DHCP Discover packet: When a device boots up and it is configured to obtain an address via DHCP, it sends a Broadcast sourced from UDP port 68 (bootpc) out to UDP port 67 (bootps). The packet will reach every device on the network, including any possible DHCP servers located there.
DHCP Offer packet: The DHCP servers on the local network see the broadcasted Discover message sent by the client and send back a response (DHCP Offer packet) using UDP source port bootps 67 and destination port bootpc 68, also in the form of a Broadcast address, because the client still doesn’t have an IP address so it cannot receive Unicast packets.
- 2. DHCP Request packet: Once the client workstation receives an offer made by the DHCP server, it will send a Broadcast (to let all DHCP servers learn that it has accepted an offer from a server) DHCP Request message to a specific DHCP server, again using UDP source port bootpc 68 and destination port bootps 67. The client might have received offers from multiple DHCP servers, but it only needs a single IP address so it must choose a DHCP server (based on an identifier), and this is usually done on a “first-come, first-served” basis.
- 3. DHCP Ack packet: The DHCP server sends another Broadcast message to confirm the IP address allocation to that specific client, again using UDP source port bootps 67 and destination port bootpc 68.
DHCP Reservations
A DHCP server can be configured to provide IP addresses in a number of different ways, including:
- Dynamic allocation
- Automatic allocation
- Static allocation
A very common approach to assigning addresses via the DHCP server is using a dynamic allocation process, in which the DHCP server is configured with a big pool of IP addresses and assigns one of them to clients based on their requests. When the device lease period expires or the device leaves the network, the particular IP address is handed back to the DHCP server, and then it can be assigned to another client.
Another method for assigning IP addresses using a DHCP server is called automatic allocation, which is a very similar process to dynamic allocation but using this approach, the DHCP server tries to keep a list of all the past assignments, and if an “old” client requests an IP address, it will be assigned the same one as before (i.e., the previous time it requested an IP address). Automatic allocation is a less efficient way of assigning IP addresses, but if you have a very large pool of IP addresses available, this is a very smart way to almost guarantee clients will get the same IP address every time they get active in a network.
Static allocation of IP addresses by a DHCP server implies defining the MAC addresses that you expect to see on the network and manually assigning a unique IP address for each of them, thus administratively building a MAC-to-IP association table. This is commonly used in a server environment because servers must use predictable IP addresses in order to be accessed.
DHCP Scopes
Network administrators who want to configure a DHCP server also need to configure DHCP scopes as part of this process. A scope is a grouping of IP addresses for a particular section of the network. Each subnet usually has its own scope.
A scope can also be a contiguous pool of addresses available for allocation by the DHCP server. Most servers also offer the functionality of excluding some addresses from the pool in order to avoid allocating them dynamically to clients. The excluded addresses are usually those IP addresses manually assigned to servers (and network devices) in the network.
Inside the defined DHCP scopes you can configure a number of parameters, such as:
- IP address range
- Subnet mask
- Lease duration
- Default gateway
- DNS server
- WINS server
Depending on the DHCP server used, you might be able to create different scopes with different parameters, usually associated with different subnets.
DHCP Leases
One of the major advantages offered by DHCP is the ability to lease an IP address, meaning assigning it on a temporary basis. Usually when a client leaves the network, that particular assigned IP address becomes free and can be allocated to another device by the DHCP server.
DHCP leases are related to every DHCP allocation and define for how long a user is allowed to use an allocated IP address. This parameter is usually administratively configured inside the DHCP scope. Whenever a client reboots it will have to ask the DHCP server again for an IP address. The DHCP server is usually configured to re-allocate the same address and extend the lease for the specific client.
Workstations can also manually release the IP address, for example, in these situations:
- The device is turned off indefinitely
- The device moves to another subnet (e.g, to a wireless network from a wired network)
The leasing process has a number of timers associated with it, so you can be sure that you are always going to have an IP address that is updated on every network device. The two important DHCP timers are as follows:
- Renewal (T1) timer (default 50% of the lease time): Whenever a workstation obtains an IP address, this timer starts up, and when 50% of the lease time has been reached, the DHCP client will try to renew its lease with the original DHCP server.
- Rebinding (T2) timer (default: 87.5% of the lease time): This second timer is used in situations in which the DHCP server does not answer or confirm the allocation extension after the renewal timer expires. This timer states that if 7/8ths of the lease time has passed, the client will try to find (send a DHCP Request) other DHCP servers which might be able to provide a DHCP address.
By having the lease process in place and correlated to the timers presented above, you can be assured that you will always have an IP address in a timely manner without any downtime associated with this and will automatically have a way to build redundancy into the DHCP process.
The T1 and T2 timers are presented in relation to the lease time in Figure 14.3 below:
Figure 14.3 – DHCP Lease Timers
DHCP Options
In DHCP, there is a special field available that helps extend the capabilities of this automatic configuration process. You can put many different configuration options inside this field, which are also present in the DHCP RFC.
|
Note: BOOTP options were called “vendor extensions.”
|
DHCP offers 256 option values, from which only 254 are usable because 0 is the pad option and 255 is the end option. Many DHCP options are commonly known parameters used often, including:
- Subnet mask
- Domain name server
- Domain name
Through the years, additional DHCP options have been added, especially for VoIP use, such as the following:
- Option 129: call server IP address
- Option 135: HTTP proxy for phone-specific applications
All of these options are configured directly on the DHCP server, but not all DHCP servers offer the ability to set DHCP options. If network administrators would like to use these features, they should utilise an enterprise-level DHCP server. When using small routers as DHCP servers for home offices, there may be no benefit from such functionalities.


