IT Certification and Training Blog

A Cisco Administrator’s Guide to DHCP

May 1, 2013 1:28:00 PM / by Kelson Lawrence

By Amy Haigh

As a network administrator, you will be responsible for ensuring that each host on your network is configured with the appropriate TCP/IP parameters to communicate with other hosts. To communicate on a network, either private or public, a host must be configured with — at minimum — an IP address, a subnet mask, and a default gateway. On a small private network with consistent hosts, you can manually configure these options on each host. But if you administer a large network, or even a small network where laptops and tablets continuously connect and disconnect, you will find implementing Dynamic Host Configuration Protocol (DHCP) to be a lifesaver.

DHCP, defined by RFC 2131, describes both the client-server model by which TCP/IP configuration parameters are assigned to a host and the protocol by which those assignments are delivered to the host. For instance, a Cisco router or switch, or even a Microsoft server configured to perform routing functions, can act as a DHCP server and assign TCP/IP parameters to requesting hosts; for a host to request and receive TCP/IP parameters from a DHCP server, that host must be configured as a DHCP client.

Here is an overview of some of the basic DHCP concepts and some of the commands necessary to implement DHCP configurations on a Cisco router.


Defining a DHCP Pool

Although using DHCP to distribute TCP/IP parameters to requesting hosts greatly simplifies your configuration effort, as a network administrator, you are responsible for ensuring that the correct parameters are assigned to DHCP clients. First, you must define the appropriate pool of IP addresses that DHCP will assign to hosts. Usually, a separate DHCP pool is configured for each physical or virtual subnet on a network. For advice on how to select the appropriate IP address range and subnet mask for a network, see Boson’s series of video presentations titled Subnetting Demystified.

Once you have identified the IP address range that you want to use for a subnet, you can define the DHCP pool. Your first step should be to ensure that the router is configured to function as a DHCP server. By default, the Cisco IOS DHCP feature is enabled on a Cisco router. However, if this feature has been disabled, you should issue the service dhcp command at the global configuration prompt to enable it:

Router(config)#service dhcp

To create a DHCP address pool name and enter DHCP pool configuration mode, you should issue the ip dhcp pool name command at the global configuration prompt. For instance, if you wanted to create a DHCP pool to correspond with VLAN 10, you might name the DHCP pool “VLAN 10”. Thus you would issue the following command:

Router(config)#ip dhcp pool VLAN10

To define the DHCP pool of addresses to be assigned to DHCP clients, you should issue the network command along with the desired network address and subnet mask. The subnet mask can be indicated by either the full subnet mask notation or by prefix notation. For instance, if the mask is 255.255.255.0, the prefix notation is /24. The full network command syntax is network network-number [mask | /prefix-length]. If you want to configure an IP address pool consisting of the 192.168.10.0 network, you should issue one of the following commands at the DHCP pool configuration mode prompt:

Router(dhcp-config)#network 192.168.10.0 255.255.255.0

OR

Router(dhcp-config)#network 192.168.10.0 /24

Note that multiple DHCP pools, each to be assigned to a different subnet, can be configured on a single DHCP server.


Excluding IP Addresses from a DHCP Pool

Because users will need consistent access to important network devices, such as servers and printers, you should ensure that such devices are configured with static IP addresses from within the IP address range implemented on the subnet. You can manually configure each of these individual devices with the desired permanent IP address; to prevent the DHCP server from assigning these devices’ IP addresses to DHCP clients, you can specifically exclude those particular addresses from the DHCP pool.

For instance, to define a DHCP exclusion range on a Cisco router functioning as a DHCP server, you should issue the ip dhcp excluded-address low-address [high-address] command in global configuration mode. Assume you plan to define a DHCP address pool consisting of the 192.168.10.0 network, and you want to reserve the IP addresses 192.168.1.1 through 192.168.1.15 for devices that need permanent IP address assignments. You should issue the following command on the Cisco router that will function as a DHCP server:

Router(config)#ip dhcp excluded-address 192.168.1.1 192.168.1.15


DHCP Leases

The DHCP server leases the appropriate TCP/IP configuration to a requesting DHCP client. The default lease duration may vary depending on the vendor of the DHCP server software, and custom lease durations can be defined, but every lease has an expiration date. To keep the same TCP/IP configuration, a client must renew the DHCP lease before it expires.

dhcp discoverTo acquire a DHCP lease, a DHCP client first broadcasts a DHCPDISCOVER message to identify the DHCP servers on the local network segment. The DHCP servers on the segment then respond directly to the client with a DHCPOFFER message. The DHCPOFFER message includes all of the necessary TCP/IP parameters. If multiple DHCP servers respond with offer messages, the client picks one of the DHCP servers — usually the first DHCP server that responded. The client then replies with a DHCPREQUEST message, confirming that it will accept the offered configuration information. Alternatively, if only one DHCP server is present on the segment and the client determines that the configuration offered by that server is incompatible with the client’s configuration, the client will respond with a DHCPDECLINE message instead of a DHCPREQUEST message.

When the DHCP server receives the DHCPREQUEST message from the client, as long as the lease is still available, the server sends the client a DHCPACK message to acknowledge that the client accepted the TCP/IP parameters. However, if the client is late in sending the DHCPREQUEST message, the server may respond with a DHCPNACK message, informing the client that the original lease is no longer available.

When a DHCP client is shut down properly, the client will issue a DHCPRELEASE message to inform the DHCP server that it no longer needs the leased TCP/IP parameters. Typically, the DHCP client will attempt to renew its lease before the lease period expires. However, if the DHCP client still has the TCP/IP configuration when the lease time expires, the client must renew its lease or request a new lease.

The default lease duration assigned by a Cisco router serving as a DHCP server is one day. But you can configure alternative lease durations by issuing the lease {days [hours] [minutes] | infinite} command at the DHCP pool configuration mode prompt. For instance, the following commands show the lease time set to 7 days, set to 10 hours, set to 30 minutes, and set to infinite, respectively:

Router(dhcp-config)#lease 7

Router(dhcp-config)#lease 0 10

Router(dhcp-config)#lease 0 0 30

Router(dhcp-config)#lease infinite


DHCP Relay Agent

A DHCP server can be configured to assign IP address pools for physical subnets to which it is not directly attached. In such situations, you must implement a DHCP relay agent to forward DHCP requests from the client to the server and forward replies from the server to the client.

Like the DHCP server feature, the DHCP relay agent feature is enabled by default on a Cisco router. However, if the DHCP relay agent feature has been disabled, you should issue the same command you issued to enable the DHCP server feature:

Router(config)#service dhcp

As mentioned earlier, when a DHCP client is in search of a DHCP server, it broadcasts a DHCPDISCOVER message. Routers do not typically forward broadcasts, so for a DHCP client on a remote subnet to contact a DHCP server, a DHCP relay agent must forward the DHCPDISCOVER message to the subnet where the DHCP server resides. As the network administrator, you are responsible for configuring the DHCP relay agent to forward these broadcasts to the appropriate DHCP server. Assume that the DHCP server is located on the subnet attached to the DHCP relay agent’s FastEthernet 0/1 interface and that the DHCP server address is 192.168.1.5. First, you must enter interface configuration mode from global configuration mode:

Router(config)#interface FastEthernet 0/1

Once the DHCP relay agent router is in interface configuration mode, you must issue the ip helper-address address command at the interface configuration prompt:

Router(config-if)#ip helper-address 192.168.1.5


Conclusion

We have covered some of the basic DHCP concepts and the related configurations that can be made on a Cisco router functioning as a DHCP server. There are many other DHCP options available, most of which are context-specific, and we recommend that you learn more about them. A good starting point is the Cisco.com article titled Configuring DHCP.

 

describe the image

Are you interested in CCENT or CCNA certification? Check out our Cisco Courseware.

Boson's Cisco Courseware

 

Topics: DHCP Relay Agent, Guide to DHCP, DHCP, DHCP pool, DHCP leases

Kelson Lawrence

Written by Kelson Lawrence

Subscribe to Email Updates

Lists by Topic

see all

Posts by Topic

see all

Recent Posts