Using Cisco Router as a DHCP Server

In this lesson, we are going to describe its features and illustrate how a Cisco router can be used as a DHCP server. Using the Security Device Manager, you will get the chance to configure the protocol, tune its components, and monitor the operations of the protocol.

Understanding DHCP Process

The Dynamic Host Configuration Protocol, also known as DHCP, is a client server application that automates the assignment of IP components to client machines. In that sense, client machines will go into the network without parameters and will request those parameters from a DHCP server.

The parameter information contained on the DHCP server ranges from the required IP address and default gateway and subnet mask to DNS servers, NetBIOS name servers, and other specialized parameters like TFTP servers and SIP servers, and the client belongs to the IP telephony world.

The specification on the RFC even includes VLAN IDs and quality of service parameters. The protocol can be based on a lease model in which machines rent their parameters and they can be reused by other machines if the original device is no longer in the network. Parameters are leased based on a certain time, which can be defined and can be different per IP address scope or per group of machines. You could also define manual allocations and fix parameters for a particular machine. Let us describe the DHCP process in more details.

DHCP Process

In this figure, we have a client requesting IP addresses from a server. It looks like three clients and two servers just to illustrate the different stages of the process, but we are talking about the same client and the same server at this point. The first thing to say here is that each one of these calls is a local broadcast in terms of IP information. This is because the clients do not know the subnet that they belong to when they start because they obviously don’t have an IP address and the servers don’t know where to reply to, because the clients don’t have an IP address yet. So all of these calls will use a local broadcast and a destination IP address on the packet.

Clients will broadcast a request message, a discover message to servers, more than one server could see that message, and so that’s why you need the four stages here. The servers will reply with an offer message, again this is still a local protest because the client does not have a local address. It is a local broadcast at layer 3 but during the discover message, the server knows the MAC address of the client, and that’s why even though at layer 3 it is a broadcast in the destination, it will be unicast later too because the server will send information straight to the MAC address of the client. So overall, that’s how the process works.

After the discover message and the offer message, then more than one server could reply with an offer message, so the client has to make a decision as to which address or which information to take. So it will reply with a request message, deciding which server will provide the information. All along, offer messages include IP addresses but also other options like default gateways, leased time, expiration time, etc. Finally, the selected server will say, “Okay. I acknowledge your request. Here is the information. Now we start a lease time, and you are the owner of the address temporarily.” And so that’s a DHCP acknowledgment message. The client will see it and will start operating.

The important thing about these being local protests is that if you place a router in the middle of the conversation, then routers will not forward local broadcasts. So you will have to configure that router so that requests and replies can travel back and forth across that router. If you are going to configure a Cisco router as a DHCP server, then he would have to support DHCP and perform all of these calls.

DHCP Address Allocation

Providing an IP address to a client is the most important task performed by a host configuration protocol. Together with that we are getting information for the network segment, default gateway, DNS servers, domain name, TFTP servers (important in the IP telephony) and so on. To provide flexibility for configuring addresses on different types of clients, the DHCP standard includes three different address allocation mechanisms:

  • Manual Allocation: Also known as reservation. A particular IP address is pre-allocated to a single device by an administrator. DHCP only communicates the IP address to the device. The IP address is mapped to the MAC address of the requesting device.
  • Automatic Allocation: DHCP automatically assigns an IP address permanently to a device, selecting it from the predefined pool of available addresses.
  • Dynamic Allocation: DHCP assigns an IP address from a pool of addresses for a limited period of time chosen by the server, or until the client tells the DHCP server that it no longer needs the address (like executing the command “ipconfig /release” under Windows OS).

Using a Router as a DHCP Server

DHCP is a critical service and your Cisco IOS router can provide full support to be a DHCP server. Many of the parameters and options defined in the RFC are present and available in IOS routers. This is important because the router will be there in the network. It is a network element that can start providing this type of server like services without the need to install and deploy a full blown server. Smaller deployments, branch offices, and home offices will benefit from this function at the network element. The service is software based and it can be fully configured in your router for multiple interfaces, multiple DHCP scopes, also supporting static assignments.

Commands and Configurations

Here is a configuration example of configuring a DHCP pool in a Cisco Router:

RouterX(config)#ip dhcp pool Marketing
RouterX(dhcp-config)#network 10.123.1.0 255.255.255.0
RouterX(dhcp-config)#default-router 10.123.1.1
RouterX(dhcp-config)#domain-name learncisco.net
RouterX(dhcp-config)#dns-server 172.16.4.10 172.16.4.12

Commands are available in the command-line interface to aid in monitoring and troubleshooting.

RouterX#show ip dhcp pool Marketing
Pool Marketing :
 Utilization mark (high/low)    : 100 / 0
 Subnet size (first/next)       : 0 / 0
 Total addresses                : 254
 Leased addresses               : 0
 Pending event                  : none
 1 subnet is currently in the pool :
 Current index        IP address range                    Leased addresses
 10.123.1.1           10.123.1.1       – 10.123.1.254      0
RouterX#

Router#sh ip dhcp conflict
IP address        Detection method   Detection time          VRF
192.168.200.58    Gratuitous ARP     May 28 2012 03:31 PM
192.168.200.59    Gratuitous ARP     May 28 2012 03:31 PM
192.168.200.64    Gratuitous ARP     May 28 2012 03:39 PM

The last command shows IP DHCP conflict. It will help you identify IP address conflicts found by the DHCP servers and clients. An address conflict occurs when the server is trying to assign an IP address and either the server or the client find that there is other devices in the network with the same IP address. Servers will ping the IP addresses on the lease before they assign them to detect conflicts and clients use gratuitous ARPs to detect all the clients with the same IP. If an address conflict is detected and the address is removed from the pool, the address is not assigned until an administrator resolves the conflict. These built-in capabilities make the IOS DHCP server a powerful tool.

Our Recommended Premium CCNA Training Resources

These are the best CCNA training resources online:

Click Here to get the Cisco CCNA Gold Bootcamp, the most comprehensive and highest rated CCNA course online with a 4.8 star rating from over 30,000 public reviews. I recommend this as your primary study source to learn all the topics on the exam. Cisco CCNA Gold Bootcamp
Want to take your practice tests to the next level? AlphaPreps purpose-built Cisco test engine has the largest question bank, adaptive questions, and advanced reporting which tells you exactly when you are ready to pass the real exam. Click here for your free trial. Cisco CCNA Gold Bootcamp