Explain the purpose and properties of DHCP. This chapter covers different aspects related to IP addressing techniques and DHCP technology. Learn what is DHCP? You configure and troubleshoot DHCP in our Cisco CCNA video course.
Address Allocation Techniques
An important aspect regarding IP addressing is the way addresses can be assigned. One way is to use static assigning and the other way is to use dynamic protocols like the Dynamic Host Configuration Protocol (DHCP). When deciding between the two address allocation methods, you must answer the following questions:
- How many end-systems do you have?
If you have a small number of hosts (less than 50), you can consider using statically assigned addresses, but if you have several hundred systems, you need to use DHCP to speed up the process.
- What does the security policy demand?
Some organizations demand the use of static IP addressing for every host or for every node in order to create a more secure environment. For example, an outsider cannot plug in his station to the network, automatically get an IP address, and have access to internal resources. The organization’s security policy might demand static addressing, regardless of the network size.
- What is the likelihood of renumbering?
This includes the possibility of acquisitions and mergers in the near future. If the likelihood of renumbering is high, DHCP should be used.
- Do you have high availability demands?
If the organization has high availability (HA) demands, DHCP should be used in redundant server architecture. Static addressing should always be used on certain network modules in certain devices, as follows:
- Corporate servers
- Network management workstations
- Standalone servers in the Access Layer submodule
- Printers and other peripheral devices in the Access Layer submodule
- Public servers in the Enterprise Edge module
- Remote access submodule devices
- WAN submodule devices
Static versus Dynamic Addressing
Before the adoption of automated ways to provide IP addressing for the devices in a network, this was performed manually. The network administrator had to go to each computer and configure the following parameters:
- IP address
- Subnet mask
- Gateway
- DNS servers
- NTP servers
In October 1993, the first automated way to allocate IP addresses was introduced: the Bootstrap Protocol (BOOTP). Even though it was a major improvement over the traditional method, BOOTP had some limitations. Because BOOTP was not able to configure every parameter, the network administrator had to manually configure some settings on devices. Another drawback of using BOOTP was that it did not have any mechanism to understand when a device might leave the network and make its IP address available for others to use.
Because of these disadvantages and lack of functionality, BOOTP was eventually upgraded to the Dynamic Host Configuration Protocol (DHCP), which was initially released in 1997 and underwent periodic upgrades over the years.
To refresh your memory, DHCP address allocation is a four-step process, as presented in Figure 10.1 below:
Figure 10.1 – DHCP Four-Step Process
- DHCP Discover: When a device boots up and it is configured to obtain an address via DHCP, it sends a Broadcast out to UDP port 67. The packet will reach every device on the network, including any possible DHCP servers located there.
- DHCP Offer: The DHCP servers on the local network see the broadcasted Discover message sent by the client and sends back a response (DHCP Offer packet) also in the form of a Broadcast address, because the client still doesn’t have an IP address so it cannot receive Unicast packets.
- DHCP Request: Once the client workstation receives an offer made by the DHCP server, it will send a Broadcast (to let all DHCP servers know that it has accepted an offer from a server) DHCP Request message to a specific DHCP server. The client might have received offers from multiple DHCP servers but it needs only 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.
- DHCP ACK: The DHCP server sends another Broadcast message to confirm the IP address allocation to that specific client.
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 for a DHCP server is to assign addresses 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 of assigning IP addresses by the DHCP server is called automatic allocation, which is a very similar process to dynamic allocation. However, using this approach, the DHCP server tries to keep a list of all of 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 the client requested an IP address). Automatic allocation of IP addresses is less efficient but if you have a very large pool of IP addresses available, this is a very smart way to almost guarantee that clients will get the same IP address every time they become 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 group 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 to avoid allocating them dynamically to clients. The excluded addresses are usually those IP addresses manually assigned to servers in the network.
A number of parameters can be configured inside the defined DHCP scopes, including the following:
- 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 the client leaves the network, that particular assigned IP address is then free to 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 is rebooting, that client will again have to ask the DHCP server for an IP address. The DHCP server is usually configured to re-allocate the same address and extend the lease for that 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 will always have an IP address that is updated on every network device. There are two important DHCP timers, as follows:
- The T1 renewal 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.
- The T2 rebinding timer (default: 87.5% of the lease time): This second timer is used in situations in which the DHCP server does not answer or confirms 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 (by sending a DHCP Request) other DHCP servers that might be able to provide a DHCP address.
With the lease process in place and correlated to the timers presented above, you can be sure that you will always have an IP address in a timely manner without any downtime associated with this; in addition, you 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 10.2 below.
Figure 10.2 – DHCP Lease Timers
DHCP Options
In DHCP, there is a special field available that helps extend the capabilities of this automatic configuration process. This field can include many different configuration options, which are also present in the DHCP RFC.
Note: BOOTP options were called vendor extensions. |
DHCP offers 256 option values, of which only 254 are usable because 0 is the pad option and 255 is the end option. Many DHCP options are commonly known parameters that are used often, including:
- Subnet mask
- DNS server
- Domain name
Through the years, additional DHCP options have been added, especially for VoIP use, such as the following:
- Option 129: 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 want to use these features, they should utilize an enterprise-level DHCP server. On the other hand, using small routers as DHCP servers for home offices may not benefit from such functionalities.
DHCP Configuration Examples
DHCP server functionality can be configured on a variety of devices, including:
- Workstations
- Servers
- Routers
- Switches
In the following sections, we will exemplify such configurations on various platforms.
DHCP Server on Cisco Routers – CLI
Many enterprise routers and switches offer DHCP server functionality. We will exemplify this on a Cisco IOS router.
The first step is enabling the DHCP service on the router. This is accomplished using the service dhcp command, as shown in the output below. DHCP is actually enabled by default on most router models by the vendor, but you may find it has been disabled by a network engineer for security reasons.
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. Router(config)#service dhcp |
The next step is to create a DHCP pool that defines the IP address pool to be allocated to clients. In this example, we will create a pool named SUBNET_A, which will offer IP addresses from the 192.168.1.0/24 range.
Router(config)#ip dhcp pool SUBNET_A
Router(dhcp-config)#network 192.168.1.0 255.255.255.0 Router(dhcp-config)#default-router 192.168.1.1 Router(dhcp-config)#dns-server 8.8.8.8 Router(dhcp-config)#domain-name Network+ Router(dhcp-config)#lease 30 |
The DHCP Pool Configuration mode is also the place where you can configure other DHCP options. In the configuration output above, the following parameters were configured:
- Default gateway: 192.168.1.1 (the router interface assigned to the network it serves as a DHCP server)
- DNS server: 8.8.8.8
- Domain name: Network+
- Lease time: 30 days
If needed, you can also configure some excluded addresses from the 192.168.1.0/24 range. Let’s say you want to exclude the router interface IP address (192.168.1.1) and the 192.168.1.200 to 192.168.1.255 range from which you would manually assign addresses to servers in your network. This is accomplished using the configuration below:
Router(config)#ip dhcp excluded-address 192.168.1.1
Router(config)#ip dhcp excluded-address 192.168.1.200 192.168.1.255 |
In order to verify the clients currently served by the router DHCP server, you can issue the show ip dhcp binding command, as illustrated below:
Router#show ip dhcp binding
Bindings from all pools not associated with VRF: IP address Client-ID/ Lease expiration Type Hardware address/ Username 192.168.1.2 0063.6973.636f.2d63. Mar 02 2014 12:07 AM Automatic 3230.322e.3237.6263. 2e30.3030.302d.4661. 302f.30 |
In the output above, a single client was served by the DHCP server and was assigned the first non-excluded IP address from the DHCP scope: 192.168.1.2. You can also see the lease expiration date and the device MAC address.
DHCP Packet Analysis
In order to practically understand the topics presented in this chapter, traffic captures on the devices involved in Figure 10.1 above will be presented for analysis. After the DHCP server is configured and the client workstation boots up, the four-step DHCP process occurs, as shown in the packet capture in Figure 10.3 below:
Figure 10.3 – DHCP Four-Step Process
The DHCP Discover packet components can be seen in Figure 10.4 below:
Figure 10.4 – DHCP Discover Packet
As you can see in the packet capture, the packet was sent by the client, who broadcasted it on the network (destination 255.255.255.255). You can see that the message type is “Boot Request (1).” The next packet is the DHCP Offer packet, which is presented in Figure 10.5 below:
Figure 10.5 – DHCP Offer Packet
This packet was sent by the server (source IP: 192.168.1.1) to the Broadcast address (destination: 255.255.255.255) and it contains the proposed IP address (192.168.1.2). You can see that the message type is “Boot Reply (2).” The third packet is the DHCP Request, which is shown in Figure 10.6 below:
Figure 10.6 – DHCP Request Packet
The DHCP Request packet is sent by the client to the Broadcast address. You can see that the message type is “Boot Request (1).” This packet is similar to the initial DHCP Discover packet but it contains a very important field, which is “Option 50: Requested IP Address” (192.168.1.2). This is the exact IP address offered by the DHCP server in the DHCP Offer packet, and the client confirms it and accepts it. The last packet in the DHCP allocation process is the DHCP Ack packet sent by the server, which is shown in Figure 10.7 below:
Figure 10.7 – DHCP ACK Packet Options
This packet is sourced by the DHCP server and broadcasted on the network, and it contains some extra fields that can be seen in the screenshot above:
- DHCP server identifier: the DHCP server IP address (192.168.1.1)
- All the options configured on the router:
- Lease time: 30 days (and the derived renewal time and rebinding time values discussed earlier)
- Subnet mask: 255.255.255.0
- Default gateway (router): 192.168.1.1
- DNS: 8.8.8.8
- Domain name: Network+
DHCP Server on Routers – GUI
While DHCP is usually configured using the command line interface (CLI) on enterprise routers, it is often configured using the graphical user interface (GUI) on lower-end home office routers. The GUI is typically accessed through a Web page, which will be exemplified here using a DD-WRT flashed router, which is very common. Figure 10.8 below shows the DHCP configuration page of such a router:
Figure 10.8 – GUI DHCP Configuration
The configuration options presented here include:
- Enabling the DHCP server
- Defining the DHCP address scope (start IP address + maximum DHCP users)
- Lease time
- DNS server
- Other options
Figure 10.9 below shows the DHCP status page, which includes the configured settings and the DHCP clients that use DHCP-allocated IP addresses:
Figure 10.9 – GUI DHCP Status
DHCP Server Software on Windows
The DHCP configuration and verification concepts presented above can also be applied when using software tools with this functionality. Although enterprise environments most often use Active Directory as the DHCP server, some other freeware utilities are available that are capable of achieving the same tasks. One of these utilities is TFTPD32.
As shown in Figure 10.10 below, the DHCP configuration screen of the TFTPD32 utility offers the following configuration options:
- DHCP address scope (start IP address + size of pool)
- DNS server
- Default gateway
- Network mask
- Domain name
- Other options
Figure 10.10 – TFTPD32 DHCP Configuration
Summary
In October 1993, the first automated way to allocate IP addresses was introduced: the Bootstrap Protocol (BOOTP). Even though it was a major improvement over the traditional method, BOOTP had some limitations, as it was not able to configure every parameter so the network administrator still had to manually configure some settings on devices.
Because of these disadvantages and lack of functionality, BOOTP was eventually upgraded to the Dynamic Host Configuration Protocol (DHCP), which was initially released in 1997 and underwent periodic upgrades over the years.
DHCP address allocation is a four-step process:
- DHCP Discover
- DHCP Offer
- DHCP Request
- DHCP ACK
A DHCP server can be configured to provide IP addresses in a number of different ways, including:
- Dynamic allocation
- Automatic allocation
- Static allocation
Network administrators who want to configure a DHCP server also need to configure DHCP scopes as part of this process. A scope is a group of IP addresses for a particular section of the network. Each subnet usually has its own scope. A number of parameters can be configured inside the defined DHCP scopes, such as:
- IP address range
- Subnet mask
- Lease duration
- Default gateway
- DNS server
- WINS server
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 the client leaves the network, that particular assigned IP address is then free to be allocated to another device by the DHCP server.
In DHCP, there is a special field available that helps extend the capabilities of this automatic configuration process. Many different configuration options can be found in this field, which are also present in the DHCP RFC.
Configure DHCP in our 101 Labs – CompTIA Network+ book.