How to Configure DHCP on Cisco IOS DevicesBy Stelios Antoniou
The Dynamic Host Configuration Protocol (DHCP) is considered to be an evolution of the Bootstrap Protocol (BootP).
DHCP is literally build upon BootP, and BootP remains an internal part of DHCP. Both protocols have been created to provide IP addresses to clients when needed.
The difference between them is that while BootP provides an IP address to a client according to the client’s hardware address on the BootP server table, DHCP by default provides an IP address automatically to the client from a pool of IP addresses.
Besides an IP address, the DHCP server can provide the client a lot of information, such as DNS server IP address, Default gateway IP address, Domain name and much more.
A Cisco IOS device can be configured to act as:
- a DHCP server – by providing IP addresses when requested to do so
- a DHCP client – when it requests an IP address
- a DHCP relay agent – when it captures IP requests from clients, adds extra information to the request for user identification purposes, and forwards the request to the DHCP server
Cisco IOS devices can be configured to act as all of the above and even in combinations of two or three of roles. In this article I will investigate the operation of Cisco routers under all of the above roles.
Cisco IOS Router Acting as a DHCP Server
Let’s start by investigating the process of IP address assignment when a DHCP client requests an IP address from a DHCP server. The messages exchanged between client and server can be seen in the diagram below:
The above diagram presents the DHCP message sequence. Here’s how it all goes down:
- The client sends a DHCP Discover message to locate a DHCP server – this is a broadcast message
- The DHCP server responds with a DHCP Offer unicast message – this message includes the IP address offered to the client, default gateway address and lease time for the IP address offered; it may also include DNS servers, TFTP server, and other information
- The client responds with a DHCP Request message which is a formal request for the IP address offered by the server – this is again a broadcast message
- Finally the server responds with a DHCP Ack unicast message confirming that the IP address has been leased to the client
Below is a list of the most important commands to enable a Cisco router to emulate a DHCP server:
Now let’s use the above commands in a real scenario. A Cisco router is configured to provide DHCP functionality as follows:
- Router(config)# ip dhcp excluded-address 172.16.1.1 172.16.1.3
- Router(config)# ip dhcp pool DATA
- Router(config-dhcp)#network 172.16.1.0 255.255.255.0
- Router(config-dhcp)#dns-server 172.16.1.1 172.16.1.21
- Router(config-dhcp)#default-router 172.16.1.1
- Router(config-dhcp)#lease 7
Based on the above configuration let’s see the messages exchanged as captured from Ethereal application. A screen shot of the messages can be seen below:
Details on the DHCP Offer message sent by the Cisco router can be seen below. Make a note of the client’s offered IP address (172.16.1.5), option 3 – default router’s address, option 51- IP address lease time, option 6 – IP addresses of DNS servers.
Cisco IOS Router Acting as a DHCP Client
A Cisco router can be configured to act as DHCP client and obtain dynamically an interface address by using the command ip address dhcp in interface configuration mode. Issuing this command causes the router to transmit DHCP Discover messages on the specific interface.
Cisco IOS Router Acting as a DHCP Relay Agent
By default routers do not forward broadcasts. In internetworks, most of the times, a DHCP server is located on a different network than the majority of its clients.
For DHCP messages to be able to reach the server, configuration of IP helper addresses is required. IP helper address [DHCP server IP address] interface command instructs a router to intercept DHCP broadcast messages and forward them as unicasts to the DHCP server hence providing “relay” functionality.
DHCP relay agents provide extra security to the network by hiding the server’s IP address from the clients. The client knows only the IP address of the relay agent.
The image below shows a common scenario where IP helper address is required.
The next image shows an IP DHCP Offer message as received on the client.
Note the IP address of the relay agent specified in the message. The client with the help of IP helper address on the relay agent is able to receive its IP address and all other information options provided.
Telecom companies use the services provided by DHCP relay agents extensively. Specifically the ip dhcp relay information option global configuration command which enables the DHCP relay agent to include information about itself to the DHCP requests sent from clients to DHCP server.
This is very useful for telecom operators when ATM routed bridge encapsulation (RBE) is used so that ATM interface and PVC over which the DHCP request came in is transmitted to the server from the relay agent. This information can be used to authenticate the client and help the DHCP server to apply the appropriate policy decisions.
The image below shows schematically the DHCP relay information option concept.
- DHCP functionality can be reliably configured on Cisco IOS devices. Cisco devices can be configured to act as DHCP servers, DHCP clients, or DHCP relay agents or even a combination of these.
- DHCP options like DNS servers, Domain name, lease time, etc. can be configured on Cisco devices.
- IP helper address activates the DHCP relay agent functionality on Cisco devices.
- DHCP relay agent options can be activated on Cisco devices so that supplementary services such as RBE functionality could be effective.
About the Author
Stelios Antoniou (CCNA, NET+, MOUS) holds a BSc in Electronic Engineering and an MSc in Communication Networks. He has over three years of experience in teaching MS Office applications, networking courses and GCE courses in Information Technology. Stelios is currently working as a VoIP Engineer in a Telecom company, where he uses his knowledge in practice. He has successfully completed training on CCNP topics, Linux and IMS. His enthusiasm, ambition and knowledge motivate him to offer his best. Stelios has written many articles covering Cisco CCENT, CCNA, and CCNP.