How to configure DHCP Server on Cisco IOS

Cisco IOS routers and layer 3 switches can be configured as DHCP server. 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 how DHCP works, take a look at my introduction to DHCP first.

Let’s use the following topology:

dhcp server example

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 /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

Now let’s configure DHCP server:

DHCP(config)#ip dhcp pool MYPOOL

Use the ip dhcp pool command to create a DHCP pool and give it a name. This DHCP pool will use network /24. Basically this is all you have to do to get 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      0063.6973.636f.2d63.    Mar 02 2002 12:24 AM    Automatic

Above you can see that we have a DHCP client and it received IP address 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               

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

Something else you might want to do is exclude a number of IP addresses. With the configuration so far our DHCP server will hand out IP address .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! Here is why:

  • 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 662 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

501 Sign Ups in the last 30 days

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

Tags: ,

Forum Replies

  1. Hi Rene,

    Nice explanation. Crisp and to the point. I have one question though.
    How would the client identify that the Offer and the Ack message that the server sends? In other words, how would the client understand that it is the intended recipient of those messages from the DHCP server. Say, for instance two new clients are connected to the network at the same time, then there would be two sets of offer and ack messages broadcasted from the server. How would each client pick the right message?


  2. Hi Saranya,
    This topic can be a little bit confusing because there are two different layers that can perform broadcast or unicast - Layer 2 and Layer 3.

    Here is a summary of what happens at each layer for each phase:

    Phase      Layer 3      Layer 2
    Discover   Broadcast    Broadcast
    Offer      Broadcast    Unicast
    Request    Broadcast    Broadcast
    Ack        Broadcast    Unicast

    Layer 3 broadcast =
    Layer 2 broadcast = FFFF.FFFF.FFFF

    You may notice that layer 3 is always broadcast. This is because the whole purpose of DHCP is for the clien

    ... Continue reading in our forum

  3. Dear Rene/Andrew,
    Thank you for this great lesson. Mr Andrew with reference to your reply # 27608 above particularly this point " Additionally, you may notice that all communication from the DHCP server at layer 2 is unicast. The reason for this is because the DHCP server obtained the client’s MAC address when the client sent out its initial Discover message.", I am still confused on where broadcast happens and where unicast happens. From the Wireshark captures above I do not see Unicast happening anywhere. Even for Offer and Ack from the server the dest mac ad

    ... Continue reading in our forum

  4. Hello Samit

    This is an excellent question and it shows that you’re thinking deeply about the subject. It is true that the DHCPOFFER when sent can technically be sent using a unicast MAC address since the MAC address of the host making the request, and thus the destination of the DHCPOFFER frame, is known. However, some operating systems and NIC drivers don’t always use this logic when operating DHCP.

    Some client implementations are unable to receive such unicast frames until the implementation has been configured with a valid IP address. Remember, when we en

    ... Continue reading in our forum

  5. Hello Swapnil

    DHCP can provide a multitude of information to hosts. The most common implementations include IP address, subnet mask, default gateway and DNS server. There are many more elements that DHCP can offer and these are called DHCP options. Some of the most common include NTP servers, log servers, cookie servers, interface MTU, default TCP TTL, NetBIOS name server and IRC chat server to name just a few.

    These options are indicated using an option number. DHCP option numbers can range any where from 0 to 255. Some of these numbers are standard vendo

    ... Continue reading in our forum

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