Using a Cisco Router as a DHCP Server
Originally, network administrators had to manually configure the host address, default gateway, and other network parameters on each host. However, DHCP provides configuration parameters to IP hosts. DHCP consists of these two components:
- A protocol for delivering host-specific configuration parameters from a DHCP server to a host
- A mechanism for allocating network addresses to hosts
DHCP is built on a client-server model. The DHCP server hosts allocate network addresses and deliver configuration parameters to dynamically configured hosts. The term client refers to a host requesting initialization parameters from a DHCP server.
DHCP supports these three mechanisms for IP address allocation:
- Automatic allocation: DHCP assigns a permanent IP address to a client.
- Dynamic allocation: DHCP assigns an IP address to a client for a limited period of time (or until the client explicitly relinquishes the address).
- Manual allocation: A client IP address is assigned by the network administrator, and DHCP is used simply to convey the assigned address to the client.
Dynamic allocation is the only one of the three mechanisms that allows automatic reuse of an address that is no longer needed by the client to which it was assigned. Dynamic allocation is particularly useful for assigning an address to a client that will be connected to the network only temporarily, or for sharing a limited pool of IP addresses among a group of clients that do not need permanent IP addresses. Dynamic allocation can also be a good choice for assigning an IP address to a new client being permanently connected to a network in which IP addresses are sufficiently scarce that it is important to reclaim them when old clients are retired.
When a DHCP client boots up for the first time, it transmits a DHCPDISCOVER message on its local physical subnet. Because the client has no way of knowing the subnet to which it belongs, the DHCPDISCOVER is an all-subnets (all-hosts) broadcast (destination IP address of 255.255.255.255). The client does not have a configured IP address; therefore, the source IP address of 0.0.0.0 is used.
A DHCP server that receives a DHCPDISCOVER message can respond with a DHCPOFFER message, which contains initial configuration information for the client. For example, the DHCP server provides the requested IP address. The subnet mask and default gateway are specified in the options field, subnet mask, and router options, respectively. Other common options in the DHCPOFFER message include IP address lease time, renewal time, domain name server, and NetBIOS Name Service (Microsoft Windows Internet Name Service [Microsoft WINS]).
After the client receives a DHCPOFFER message, it responds with a DHCPREQUEST message, indicating its intent to accept the parameters in the DHCPOFFER.
After the DHCP server receives the DHCPREQUEST message, it acknowledges the request with a DHCPACK message, thus completing the initialization process. Using a Cisco Router as a DHCP Server
Cisco routers running Cisco IOS Software provide full support for a router to be a DHCP server. The Cisco IOS DHCP server is a full DHCP server implementation that assigns and manages IP addresses from specified address pools within the router to DHCP clients. You can configure a DHCP server to assign additional parameters, such as the IP address of the Domain Name System (DNS) server and the default router.
The Cisco IOS DHCP server accepts address assignment requests and renewals and assigns the addresses from predefined groups of addresses contained within DHCP address pools.
These address pools can also be configured to supply additional information to the requesting client, such as the IP address of the DNS server, the default router, and other configuration parameters. The Cisco IOS DHCP server can accept broadcasts from locally attached LAN segments or from DHCP requests that have been forwarded by other DHCP relay agents within the network.
Using Cisco SDM to Enable the DHCP Server Function
This topic describes how to use the Cisco Router and Security Device Manager (SDM) to enable the DHCP server function on the router. Figure 4-48 shows how to configure DHCP from SDM.
For this example, you will enable the DHCP server for the 10.4.4.11/24 interface using a pool of addresses from 10.4.4.100 through 10.4.4.200. This router will be advertised as the default router (default gateway to the clients).
The DHCP server function is enabled on the Additional Tasks tab. Click DHCP Pools in the directory. Then click Add to create the new DHCP pool. The Add DHCP Pool window allows you to configure the DHCP IP address pool. The IP addresses that the DHCP server assigns are drawn from a common pool that you configure by specifying the starting and ending IP addresses in the range. The Add DHCP Pool window shows the following fields:
- DHCP Pool Name: A character string that identifies the DHCP pool.
- DHCP Pool Network and Subnet Mask: The IP addresses that the DHCP server assigns are drawn from a common pool that you configure by specifying the starting IP address in the range and the ending address in the range.
The address range that you specify should be within the following private address ranges:
- 10.0.0.0 to 10.255.255.255
- 172.16.0.0 to 172.31.255.255
- 192.168.0.0 to 192.168.255.255
The address range that you specify must also be in the same subnet as the IP address of the LAN interface. With a /24 mask, the range can represent a maximum of 254 addresses. The following examples are valid ranges with a /24 mask:
- 10.1.1.1 to 10.1.1.254 (assuming LAN IP address is in the 10.1.1.0/24 subnet)
- 172.16.1.1 to 172.16.1.254 (assuming LAN IP address is in the 172.16.1.0/24 subnet)
SDM configures the router to automatically exclude the LAN interface IP address in the pool. You must not use the following reserved addresses in the range of addresses that you specify:
- The network or subnetwork IP address.
- The broadcast address on the network.
- Starting IP: Enter the beginning of the range of IP addresses for the DHCP server to use in assigning addresses to devices on the LAN. This is the lowest-numbered IP address in the range.
- Ending IP: Enter the highest-numbered IP address in the range of IP addresses.
- Lease Length: The amount of time that the client can use the assigned address before it must be renewed.
- DHCP Options: Use this pane to configure DHCP options that will be sent to hosts on the LAN that request IP addresses from the router. These are not options for the router that you are configuring; these are parameters that will be sent to the requesting hosts on the LAN. To set these properties for the router, click Additional Tasks on the SDM category bar, click DHCP, and configure these settings in the DHCP Pool window.
- DNS Server1: The DNS server is typically a server that maps a known device name with its IP address. If you have a DNS server configured for your network, enter the IP address for the server here.
- DNS Server2: If there is an additional DNS server on the network, you can enter the IP address for that server in this field.
- Domain Name: The DHCP server that you are configuring on this router will provide services to other devices within this domain. Enter the name of the domain.
- WINS Server1: Some clients might require Microsoft WINS to connect to devices on the Internet. If there is a Microsoft WINS server on the network, enter the IP address for the server in this field.
- WINS Server2: If there is an additional Microsoft WINS server on the network, enter the IP address for the server in this field.
- Default Router: The IP address that will be provided to the client for use as the default gateway.
- Import All DHCP Options into the DHCP Server Database: This check box allows the DHCP options to be imported from a higher-level server, and is typically used in conjunction with an Internet DHCP server.
Monitoring DHCP Server Functions
You can check the DHCP configuration parameters from the DHCP Pools tab. You can also view additional information on the leased addresses by clicking DHCP Pool Status. The DHCP Pool Status window shows a list of the currently leased addresses, as shown in Figure 4-49.
To display address conflicts found by a DHCP server when addresses are offered to the client, use the show ip dhcp conflict command in user EXEC or privileged EXEC mode: show ip dhcp conflict [ ip- address]
The server uses ping to detect conflicts. The client uses Gratuitous Address Resolution Protocol (ARP) to detect clients. If an address conflict is detected, the address is removed from the pool and the address is not assigned until an administrator resolves the conflict.
Example 4-17 displays the detection method and detection time for all IP addresses offered by the DHCP server that have conflicts with other devices. Table 4-12 outlines the field descriptions.
Example 4-17 Detection Method and Detection Time
Router# show ip dhcp conflict IP address Detection Method Detection time 172.16.1.32 Ping Feb 16 1998 12:28 PM 172.16.1.64 Gratuitous ARP Feb 23 1998 08:12 AM