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







