|
|
This chapter describes how to configure Dynamic Host Configuration Protocol (DHCP). For a complete description of the DHCP commands listed in this chapter, refer to the "DHCP Commands" chapter of the Cisco IOS IP and IP Routing Command Reference publication. To locate documentation of other commands that appear in this chapter, use the command reference master index or search online.
As explained in RFC 2131, Dynamic Host Configuration Protocol, DHCP provides configuration parameters to Internet hosts. DHCP consists of two components: a protocol for delivering host-specific configuration parameters from a DHCP server to a host and a mechanism for allocating network addresses to hosts. DHCP is built on a client/server model, where designated DHCP server hosts allocate network addresses and deliver configuration parameters to dynamically configured hosts.
DHCP supports three mechanisms for IP address allocation:
The format of DHCP messages is based on the format of Bootstrap Protocol (BOOTP) messages, which ensures support for BOOTP relay agent functionality and interoperability between BOOTP clients and DHCP servers. BOOTP relay agents eliminate the need for deploying a DHCP server on each physical network segment. BOOTP is explained in RFC 951, Bootstrap Protocol (BOOTP), and RFC 1542, Clarifications and Extensions for the Bootstrap Protocol.
The Cisco IOS DHCP server feature is a full DHCP server implementation that assigns and manages IP addresses from specified address pools within the router to DHCP clients. If the Cisco IOS DHCP server cannot satisfy a DHCP request from its own database, it can forward the request to one or more secondary DHCP servers defined by the network administrator.
Figure 14 shows the basic steps that occur when a DHCP client requests an IP address from a DHCP server. The client, Host A, sends a DHCPDISCOVER broadcast message to locate a Cisco IOS DHCP server. A DHCP server offers configuration parameters (such as an IP address, a MAC address, a domain name, and a lease for the IP address) to the client in a DHCPOFFER unicast message.

![]() |
Note A DHCP client may receive offers from multiple DHCP servers and can accept any one of the offers; however, the client usually accepts the first offer it receives. Additionally, the offer from the DHCP server is not a guarantee that the IP address will be allocated to the client; however, the server usually reserves the address until the client has had a chance to formally request the address. |
The client returns a formal request for the offered IP address to the DHCP server in a DHCPREQUEST broadcast message. The DHCP server confirms that the IP address has been allocated to the client by returning a DHCPACK unicast message to the client.
![]() |
Note The formal request for the offered IP address (the DHCPREQUEST message) that is sent by the client is broadcast so that all other DHCP servers that received the DHCPDISCOVER broadcast message from the client can reclaim the IP addresses that they offered to the client. If the configuration parameters sent to the client in the DHCPOFFER unicast message by the DHCP server are invalid (a misconfiguration error exists), the client returns a DHCPDECLINE broadcast message to the DHCP server. The DHCP server will send to the client a DHCPNAK denial broadcast message, which means the offered configuration parameters have not been assigned, if an error has occurred during the negotiation of the parameters or the client has been slow in responding to the DHCPOFFER message (the DHCP server assigned the parameters to another client) of the DHCP server. |
The Cisco IOS DHCP server feature offers the following benefits:
Before you configure the Cisco IOS DHCP server feature, complete the following tasks:
![]() |
Note Inherited parameters can be overridden. For example, if a parameter is defined in both the natural network and a subnetwork, the definition of the subnetwork is used. Address leases are not inherited. If a lease is not specified for an IP address, by default, the DHCP server assigns a one-day lease for the address. |
To configure the Cisco IOS DHCP server feature, first configure a database agent or disable conflict logging, then configure IP addresses that the DHCP server should not assign (excluded addresses) and should assign (a pool of available IP addresses) to requesting clients. These configuration tasks are explained in the following sections. Each task in the following list is identified as required or optional.
A DHCP database agent is any host, for example, an FTP, TFTP, or RCP server that stores the DHCP bindings database. You can configure multiple DHCP database agents and you can configure the interval between database updates and transfers for each agent. To configure a database agent and database agent parameters, use the following command in global configuration mode:
| Command | Purpose |
|---|---|
Router(config)# ip dhcp database url [timeout seconds | write-delay seconds] | Configures the database agent and the interval between database updates and database transfers. |
If you choose not to configure a DHCP database agent, disable the recording of DHCP address conflicts on the DHCP server. To disable DHCP address conflict logging, use the following command in global configuration mode:
| Command | Purpose |
|---|---|
Router(config)# no ip dhcp conflict logging | Disables DHCP address conflict logging. |
The DHCP server assumes that all IP addresses in a DHCP address pool subnet are available for assigning to DHCP clients. You must specify the IP address that the DHCP server should not assign to clients. To do so, use the following command in global configuration mode:
| Command | Purpose |
|---|---|
Router(config)# ip dhcp excluded-address low-address [high-address] | Specifies the IP addresses that the DHCP server should not assign to DHCP clients. |
You can configure a DHCP address pool with a name that is a symbolic string (such as "engineering") or an integer (such as 0). Configuring a DHCP address pool also places you in DHCP pool configuration mode---identified by the (config-dhcp)# prompt---from which you can configure pool parameters (for example, the IP subnet number and default router list). To configure a DHCP address pool, complete the required tasks in the following sections.
To configure the DHCP address pool name and enter DHCP pool configuration mode, use the following command in global configuration mode:
| Command | Purpose |
|---|---|
Router(config)# ip dhcp pool name | Creates a name for the DHCP server address pool and places you in DHCP pool configuration mode (identified by the config-dhcp# prompt). |
To configure a subnet and mask for the newly created DHCP address pool, which contains the range of available IP addresses that the DHCP server may assign to clients, use the following command in DHCP pool configuration mode:
| Command | Purpose |
|---|---|
Router(config-dhcp)# network network-number [mask | /prefix-length] | Specifies the subnet network number and mask of the DHCP address pool. The prefix length specifies the number of bits that comprise the address prefix. The prefix is an alternative way of specifying the network mask of the client. The prefix length must be preceded by a forward slash(/). |
The domain name for a DHCP client places the client in the general grouping of networks that make up the domain. To configure a domain name string for the client, use the following command in DHCP pool configuration mode:
| Command | Purpose |
|---|---|
Router(config-dhcp)# domain-name domain | Specifies the domain name for the client. |
DHCP clients query DNS IP servers when they need to correlate host names to IP addresses. To configure the DNS IP servers that are available to a DHCP client, use the following command in DHCP pool configuration mode:
| Command | Purpose |
|---|---|
Router(config-dhcp)# dns-server address [address2 ... address8] | Specifies the IP address of a DNS server that is available to a DHCP client. One IP address is required; however, you can specify up to eight IP addresses in one command line. |
Windows Internet Naming Service (WINS) is a name resolution service that Microsoft DHCP clients use to correlate host names to IP addresses within a general grouping of networks. To configure the NetBIOS WINS servers that are available to a Microsoft DHCP client, use the following command in DHCP pool configuration mode:
| Command | Purpose |
|---|---|
Router(config-dhcp)# netbios-name-server address [address2 ... address8] | Specifies the NetBIOS WINS server that is available to a Microsoft DHCP client. One address is required; however, you can specify up to eight addresses in one command line. |
The NetBIOS node type for Microsoft DHCP clients can be one of four settings: broadcast, peer-to-peer, mixed, or hybrid. To configure the NetBIOS node type for a Microsoft DHCP, use the following command in DHCP pool configuration mode:
| Command | Purpose |
|---|---|
Router(config-dhcp)# netbios-node-type type | Specifies the NetBIOS node type for a Microsoft DHCP client. |
After a DHCP client has booted, the client begins sending packets to its default router. The IP address of the default router should be on the same subnet as the client. To configure a default router for a DHCP client, use the following command in DHCP pool configuration mode:
| Command | Purpose |
|---|---|
Router(config-dhcp)# default-router address [address2 ... address8] | Specifies the IP address of the default router for a DHCP client. One IP address is required, although you can specify up to eight addresses in one command line. |
By default, each IP address assigned by a DHCP server comes with a one-day lease, which is the amount of time that the address is valid. To change the lease value for an IP address, use the following command in DHCP pool configuration mode:
| Command | Purpose |
|---|---|
Router(config-dhcp)# lease {days [hours][minutes] | infinite} | Specifies the duration of the lease. The default is a one-day lease. |
An address binding is a mapping between the IP address and MAC address of a client. The IP address of a client can be assigned manually by an administrator or assigned automatically from a pool by a DHCP server.
Manual bindings are IP addresses that have been manually mapped to the MAC addresses of hosts that are found in the DHCP database. Manual bindings are stored in NVRAM on the DHCP server. Manual bindings are just special address pools. There is no limit on the number of manual bindings.
Automatic bindings are IP addresses that have been automatically mapped to the MAC addresses of hosts that are found in the DHCP database. Automatic bindings are stored on a remote host called a database agent. The bindings are saved as text records for easy maintenance.
To configure a manual binding, first create a host pool, then specify the IP address of the client and hardware address or client identifier. The hardware address is the MAC address. The client identifier, which is required for Microsoft clients (instead of hardware addresses), is formed by concatenating the media type and the MAC address of the client. Refer to the "Address Resolution Protocol Parameters" section of RFC1700, Assigned Numbers, for a list of media type codes.
To configure manual bindings, use the following commands beginning in global configuration mode:
| Command | Purpose | |
|---|---|---|
Step1 | Router(config)# ip dhcp pool name | Creates a name for the a DHCP server address pool and places you in DHCP pool configuration mode---identified by the (config-dhcp)# prompt. |
Step2 | Router(config-dhcp)# host address [mask| /prefix-length] | Specifies the IP address and subnet mask of the client. The prefix length specifies the number of bits that comprise the address prefix. The prefix is an alternative way of specifying the network mask of the client. The prefix length must be preceded by a forward slash(/). |
Step3 | Router(config-dhcp)# hardware-address hardware-address type | Specifies a hardware address for the client.
Specifies the distinct identification of the client in dotted-hexadecimal notation, for example, 01b7.0813.8811.66, where 01 represents the Ethernet media type. |
Step4 | Router(config-dhcp)# client-name name | (Optional) Specifies the name of the client using any standard ASCII character. The client name should not include the domain name. For example, the name mars should not be specified as mars.cisco.com. |
The boot file is used to store the boot image for the client. The boot image is generally the operating system the client uses to load. To specify a boot file for the DHCP client, use the following command in DHCP pool configuration mode:
| Command | Purpose |
|---|---|
Router(config-dhcp)# bootfile filename | Specifies the name of the file that is used as a boot image. |
By default, the DHCP server pings a pool address twice before assigning the address to a requesting client. If the ping is unanswered, the DHCP server assumes (with a high probability) that the address is not in use and assigns the address to the requesting client. To change the number of ping packets the DHCP server should send to the pool address before assigning the address, use the following command in global configuration mode:
| Command | Purpose |
|---|---|
Router(config)# ip dhcp ping packets number | Specifies the number of ping packets the DHCP server sends to a pool address before assigning the address to a requesting client. The default is two packets. |
By default, the DHCP server waits 500milliseconds before timing out a ping packet. To change the amount of time the server waits, use the following command in global configuration mode:
| Command | Purpose |
|---|---|
Router(config)# ip dhcp ping timeout milliseconds | Specifies the amount of time the DHCP server must wait before timing out a ping packet. The default 500 milliseconds. |
By default, the CiscoIOS DHCP server feature is enabled on your router. If the feature is disabled, use the following command in global configuration mode to reenable the CiscoIOS DHCP server feature on your router:
| Command | Purpose |
|---|---|
Router(config)# service dhcp | Enables the CiscoIOS DHCP server feature on your router. Use the no form of this command to disable the CiscoIOS DHCP server feature. |
To clear DHCP server variables, use the following commands in privileged EXEC mode, as needed:
| Command | Purpose |
|---|---|
Router# clear ip dhcp binding address | * | Deletes an automatic address binding from the DHCP database. Specifying address clears the automatic binding for a specific (client) IP address, whereas specifying asterisk (*) clears all automatic bindings. |
Router# clear ip dhcp conflict address | * | Clears an address conflict from the DHCP database. Specifying address clears the conflict for a specific IP address whereas specifying an asterisk (*) clears conflicts for all addresses. |
Router# clear ip dhcp server statistics | Resets all DHCP server counters to 0. |
To enable DHCP server debugging, use the following command in privileged EXEC mode:
| Command | Purpose |
|---|---|
Router# debug ip dhcp server {events | packets | linkage} | Enables debugging on the DHCP server. |
To display DHCP server information, use the following commands in EXEC mode, as needed:
| Command | Purpose | ||
|---|---|---|---|
Router> show ip dhcp binding [address] | Displays a list of all bindings created on a specific DHCP server. | ||
Router> show ip dhcp conflict [address] | Displays a list of all address conflicts recorded by a specific DHCP server. | ||
Router# show ip dhcp database [url] | Displays recent activity on the DHCP database.
| ||
Router> show ip dhcp server statistics | Displays count information about server statistics and messages sent and received. |
This section provides the following configuration examples:
ip dhcp database ftp://user:password@172.16.4.253/router-dhcp write-delay 120
In the following example, three DHCP address pools are created: one in network 172.16.0.0, one in subnetwork 172.16.1.0, and one in subnetwork 172.16.2.0. Attributes from network 172.16.0.0, such as the domain name, DNS server, NetBIOS name server, and NetBIOS node type, are inherited in subnetworks 172.16.1.0 and 172.16.2.0. In each pool, clients are granted 30-day leases and all addresses in each subnetwork, except the excluded addresses, are available to the DHCP server for assigning to clients. Table 5 lists the IP addresses for the devices in three DHCP address pools.
| Pool 0 (Network 172.16.0.0) | Pool 1 (Subnetwork 172.16.1.0) | Pool 2 (Subnetwork 172.16.2.0) | |||
|---|---|---|---|---|---|
| Device | IP Address | Device | IP Address | Device | IP Address |
Default routers | - | Default routers | 172.16.1.100 172.16.1.101 | Default routers | 172.16.2.100 172.16.2.101 |
DNS server | 172.16.1.102 --- 172.16.2.102 | --- | --- | --- | --- |
NetBIOS name server | 172.16.1.103 --- 172.16.2.103 | --- | --- | --- | --- |
NetBIOS node type | h-node | --- | --- | --- | --- |
ip dhcp database ftp://user:password@172.16.4.253/router-dhcp write-delay 120ip dhcp excluded-address 172.16.1.100 172.16.1.103ip dhcp excluded-address 172.16.2.100 172.16.2.103!ip dhcp pool 0network 172.16.0.0 /16domain-name cisco.comdns-server 172.16.1.102 172.16.2.102netbios-name-server 172.16.1.103 172.16.2.103netbios-node-type h-node!ip dhcp pool 1network 172.16.1.0 /24default-router 172.16.1.100 172.16.1.101lease 30!ip dhcp pool 2network 172.16.2.0 /24default-router 172.16.2.100 172.16.2.101lease 30
ip dhcp pool Mars host 172.16.2.254 hardware-address 02c7.f800.0422 ieee802 client-name Mars
Because attributes are inherited, the previous configuration is equivalent to the following:
ip dhcp pool Mars host 172.16.2.254 mask 255.255.255.0 hardware-address 02c7.f800.0422 ieee802 client-name Mars default-router 172.16.2.100 172.16.2.101 domain-name cisco.com dns-server 172.16.1.102 172.16.2.102 netbios-name-server 172.16.1.103 172.16.2.103 netbios-node-type h-node
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Posted: Wed Jul 26 18:21:04 PDT 2000
Copyright 1989-2000©Cisco Systems Inc.