How to configure DHCP Server on Cisco IOS

Cisco IOS routers and layer 3 switches can be configured as DHCP servers. It’s quite easy to do this and in this short lesson, I want to explain to you how to do this and how to verify your configuration. If you are a little fuzzy about how DHCP works, take a look at my introduction to DHCP first.

Let’s use the following topology:

Cisco Dhcp R1 Switch Host

Above, we have a router that I will call ‘DHCP’. The router and computer are connected to each other using a simple switch and in the same VLAN. We will use the 192.168.12.0 /24 subnet for this demonstration. Let’s prepare the interface first:

DHCP(config)#interface fastEthernet 0/0
DHCP(config-if)#no shutdown
DHCP(config-if)#ip address 192.168.12.1 255.255.255.0

Now let’s configure the DHCP server:

DHCP(config)#ip dhcp pool MYPOOL
DHCP(dhcp-config)#network 192.168.12.0 255.255.255.0

Use the ip dhcp pool command to create a DHCP pool and give it a name. This DHCP pool will use network 192.168.12.0 /24. Basically, this is all you have to do to get the DHCP server going, there is no need to start a service or something. We can verify that we have DHCP clients using the following command:

DHCP#show ip dhcp binding 
Bindings from all pools not associated with VRF:
IP address          Client-ID/	 	    Lease expiration        Type
		    Hardware address/
		    User name
192.168.12.2      0063.6973.636f.2d63.    Mar 02 2002 12:24 AM    Automatic
                    6330.372e.3132.3265.
                    2e30.3030.302d.4661.
                    302f.30

Above, you can see that we have a DHCP client that received IP address 192.168.12.2. In production networks, we will also use DHCP to hand out some other useful things like a default gateway, DNS server, and more. Let’s see how we can do this:

DHCP(config)#ip dhcp pool MYPOOL               
DHCP(dhcp-config)#default-router 192.168.12.1
DHCP(dhcp-config)#dns-server 208.67.222.222

Above, I configured the IP address 192.168.12.1 as the default gateway for the DHCP clients with the default-router command. The dns-server commands let us specify a DNS server.

Something else you might want to do is exclude some IP addresses. With the configuration so far, our DHCP server will hand out IP addresses .2,3,4,5,6, etc. Here’s how to do it:

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now!

  • Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.
  • Try for Just $1. The Best Dollar You’ve Ever Spent on Your Cisco Career!
  • Full Access to our 799 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)
541 Sign Ups in the last 30 days
satisfaction-guaranteed

  • 100% Satisfaction Guaranteed!
  • You may cancel your monthly membership at any time.
  • No Questions Asked!

Tags: ,


Forum Replies

  1. Before you create the dhcp pool, you should configure the ip dhcp excluded-address command.

  2. How i can configure a fast-Ethernet interface to act as a DHCP client? and, is there any configuration we need to do apart from the configuration you have shown in DHCP server for that?

  3. Hi Rohan,

    You can configure a FastEthernet interface to use DHCP client by using the “ip address dhcp” command under the interface.

    That’s it…

    Rene

  4. thank you very good but i wanna to know Are the messages (discover,offer,request and ack ) still broadcast or change ?

41 more replies! Ask a question or join the discussion by visiting our Community Forum