How to Configure IP DHCP Server on Cisco Router/L3 Switch

Now we describe how to configure basic Dynamic Host Configuration Protocol (DHCP) on Cisco Router and switch. DHCP (Dynamic Host Configuration Protocol) is the protocol used by network devices (such as PCs, network printers, etc) to automatically obtain correct network parameters so they can access network and Internet resources such as IP Address, Default Gateway, Domain Name, DNS Servers and more. The above Network devices which are getting network parameters from DHCP server also called as DHCP clients.

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. A DHCP Server is most necessary in today’s networks. You usally found  Windows servers, routers and layer 3 switches to run DHCP services.

DHCP Server Configuration Steps on Cisco Router or Layer 3 Switch

To configure Cisco IOS DHCP Server, follow below steps, which include sample commands:

To Enable the DHCP service in the Cisco Router or Switch, execute “service dhcp” command in global configuration mode.

Router(config)#service dhcp

To disable the DHCP service in the Cisco Router or Switch, execute “no service dhcp” command  in global configuration mode.

Router(config)#no service dhcp

Note: DHCP service is enabled by default on Cisco router.

1. Configure an IP address on the router’s Ethernet or Fast Ethernet port for LAN, and bring up the interface by using no shut command.

Router(config)# interface Fastethernet 1/1
Router(config-if)#ip address 10.4.0.1 255.255.252.0
Router(config-if)# no shutdown

2. Configure a DHCP Pool Name for your LAN IP network you want to use.

Router(config)# ip dhcp pool  DHCP-Pool-Name

3. Add network and subnet to the DHCP Pool.

Router(dhcp-config)# network 10.4.0.0 255.255.252.0

4. Add Default gateway to the DHCP clients.

Router(dhcp-config)#default-router 10.4.0.1

5. Specify the domain name for the DHCP clients.

Router(dhcp-config)#domain-name yourdomain.com

6. Specify the primary and secondary DNS servers for the DHCP clients.

Router(dhcp-config)#dns-server 10.4.0.50 4.2.2.2

7. Set the lease duration for the addresses getting  from the DHCP pool.

Router(dhcp-config)#lease 8

8. Exit from DHCP Configuration Mode.

Router(dhcp-config)#exit

Exclude IP addresses from the DHCP pool

9. To avoid the conflicts caused by the DHCP with which we statically configured IP addresses in the same range of the DHCP pool. Use below command to exclude a single address or range of IP addresses from DHCP pool.

Router(config)# ip dhcp excluded-address 10.4.0.50
Router(config)# ip dhcp excluded-address 10.4.0.1 10.4.0.50

This takes you back to global configuration prompt and you can exclude any address from DHCP pool.

Configure DHCP Reservation Feature

If your network configuration doesn’t change very often you can allocate the same IP address to a DHCP client for indefinite time. Cisco offers the DHCP reservation feature which allows you to manually bind an IP address to a MAC address and thus a device will always receive the same IP address. To configure a manual binding, you need to create a host pool first, then specify the IP address and hardware address of the client or client identifier. Use the following sequence of commands beginning in global configuration mode:

Router(config)#ip dhcp pool Server1
Router(dhcp-config)#host 10.4.1.50 255.255.252.0
Router(dhcp-config)#client-identifier 0100.2C4E.F176.41
Router(dhcp-config)#client-name Server1

Here the ‘host‘ statetement specifies the IP address (10.4.1.50) and subnet mask of the client (255.255.252.0). The subnet mask can also be specified using a prefix length (/22). The client identifier is the unique identification of the client in hexadecimal and is composed from a MAC address and the media type. Here the MAC address is 002C.4EF1.7641 and the media type is 01 meaning Ethernet. Optionally you can specify a client name to be assigned to the device (Server1 in my case).

Note!: You must perform these steps and allocate a separate DHCP pool for each static client you want to configure.

Configure the DHCP client on Router Interface

Use the following commands to configure DHCP client on Router FastEthernet 0/1 interface.

Router# configure terminal
Router(config)# interface fastethernet 0/1
Router(config-if)# ip address dhcp
Router(config-if)# no shutdown

Troubleshooting DHCP Statistics on Cisco Router

Use the following commands to check the DHCP operation on the  Cisco Router:

Router#sh ip dhcp ?

binding   DHCP address bindings

conflict  DHCP address conflicts

database  DHCP database agents

import    Show Imported Parameters

pool      DHCP pools information

relay     Miscellaneous DHCP relay information

server    Miscellaneous DHCP server information

Below command shows the current bindings of addresses given to DHCP clients

Router#show ip dhcp binding

Bindings from all pools not associated with VRF:

IP address          Client-ID/              Lease expiration        Type

Hardware address/

User name

10.4.3.100          0100.1e37.184d.1c       Sep 06 2012 12:59 PM    Automatic

10.4.3.105          01ec.55f9.4c03.9b       Sep 06 2012 07:52 PM    Automatic

10.4.3.106          015c.ac4c.30db.a0       Sep 06 2012 02:58 PM    Automatic

10.4.3.107          01ec.55f9.4c90.74       Sep 06 2012 01:01 PM    Automatic

10.4.3.109          0100.1e37.184d.0c       Sep 06 2012 09:56 AM    Automatic

10.4.3.110          015c.ac4c.3165.cc       Sep 06 2012 06:57 PM    Automatic

10.4.3.113          0110.78d2.4d50.fc       Sep 06 2012 11:51 AM    Automatic

10.4.3.117          0100.1e37.1855.d3       Sep 06 2012 05:23 PM    Automatic

10.4.3.120          01c8.0aa9.ce71.11       Sep 06 2012 05:15 PM    Automatic

Below command show the DHCP server statistics.

Router#show ip dhcp server statistics

Memory usage         21269
Address pools        1
Database agents      0
Automatic bindings   39
Manual bindings      0
Expired bindings     840
Malformed messages   172
Secure arp entries   0

Message              Received
BOOTREQUEST          0
DHCPDISCOVER         1989
DHCPREQUEST          8097
DHCPDECLINE          5
DHCPRELEASE          62
DHCPINFORM           30553

Message              Sent
BOOTREPLY            0
DHCPOFFER            1989
DHCPACK              38461
DHCPNAK              77

Below command used to get DHCP pool details.

Router#sh ip dhcp pool

Pool DHCP-Pool-Name :
Utilization mark (high/low)    : 100 / 0
Subnet size (first/next)       : 0 / 0
Total addresses                : 1022
Leased addresses               : 39
Pending event                  : none
1 subnet is currently in the pool :
Current index        IP address range                    Leased addresses
10.4.3.180           10.4.0.1         – 10.4.3.254        39

13. Below debug command is used to troubleshoot DHCP issues.

Router#debug ip dhcp server

 

Video – DHCP Server Configuration on Cisco Router or L3 Switch

This video covers the DHCP service configuration on Cisco Router or L3 Switch.

Share/Bookmark

Filed Under: DHCP

Tags:

About the Author:

RSSComments (10)

Leave a Reply | Trackback URL

  1. Ram says:

    DNS Servers are manually configured by the System admin… In the above example the DNS Servers are assigned IP from the Excluded range because DNS Servers need to be configured by Static IP’s..

  2. trying to find you on facebook, wats your profile

  3. Armin says:

    almost its very useful DHCP configuration :

    Explain the lease duration for the addresses you’re using from the pool.

    Router(dhcp-config)#lease 8

    • admin says:

      Hi Armin,

      Find the below configuration example and explanation to understand DHCP lease period.

      Router(config)#ip dhcp pool LAN-Network
      Router(dhcp-config)#lease 5 12 30
      Router(dhcp-config)#end
      Router#

      With The lease command, you are left three options: lease days, hours, minutes with hours and minutes being optional. You can specify a maximum period of 365 days, 23 hours and 59 minutes, and a minimum of 1 second. The default is 1 day.

      Router(dhcp-config)#lease 8

      DHCP lease 8 means 8 days and remaining hours & minutes are optional.

      You can also configure Cisco router to assign DHCP IP addresses with infinite lease period.

      Use the following command:

      Router#configure terminal
      Router(config)#ip dhcp pool LAN-Network
      Router(dhcp-config)#lease infinite
      Router(dhcp-config)#end
      Router#

      Thanks

  4. Somu says:

    This post covered complete DHCP configuration steps and troubleshooting steps on Cisco Router.

    Very nice one….

  5. Azar says:

    Very nicely covered to find DHCP statics and troubleshooting on Cisco Router.

  6. Sam says:

    You can run a Cisco router as a DHCP server very easily and it will simplify a network configuration by centralizing DHCP services in a large network.

    Below example shows a Cisco router configuration as a basic DHCP server in the 192.168.2.0/24 network. The DHCP options implemented are default-router (DHCP option 3) and dns-server (DHCP option 6). Two DNS servers are configured. With the excluded-address commands, using only ip addresses between 192.168.2.200-192.168.2.240 will be available for client use.

    conf t
    service dhcp
    ip dhcp pool LAN-Network
    network 192.168.2.0 255.255.255.0
    default-router 192.168.2.1
    dns-server 192.168.2.5 192.168.2.6
    exit
    ip dhcp excluded-address 192.168.2.1 192.168.2.199
    ip dhcp excluded-address 192.168.2.241 192.168.2.255

  7. Jordana says:

    Very interesting about configuring IP DHCP server on Cisco Router or L3 Switch and I love your website. It is really cool.

  8. Amjad says:

    Thank you for sharing excellent information. Your site is so cool. I’m impressed by the info that you have on this blog. It reveals how nicely you understand this subject.

  9. Sandesh says:

    Pretty great post. I simply stumbled upon this post to configure IP DHCP server on Cisco Router or Switch. In any case I’ll be subscribing in your feed and I’m hoping you write again soon!

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.