Home > DHCP Tutorial

DHCP Tutorial

June 18th, 2015 Go to comments

In IP environment, before a computer can communicate to another one, they need to have their own IP addresses. There are two ways of configuring an IP address on a device:
+ Statically assign an IP address. This means we manually type an IP address for this computer
+ Use a protocol so that the computer can obtain its IP address automatically (dynamically). The most popular protocol nowadays to do this task is called Dynamic Host Configuration Protocol (DHCP) and we will learn about it in this tutorial.

A big advantage of using DHCP is the ability to join a network without knowing detail about it. For example you go to a coffee shop, with DHCP enabled on your computer, you can go online without doing anything. Next day you go online at your school and you don’t have to configure anything either even though the networks of the coffee shop and your school are different (for example, the network of the coffee shop is while that of your company is Really nice, right? Without DHCP, you have to ask someone who knows about the networks at your location then manually choosing an IP address in that range. In bad situation, your chosen IP can be same as someone else who is also using that network and an address conflict may occur. So how can DHCP obtain an suitable IP address for you automatically? Let’s find out.


How DHCP works

1. When a client boots up for the first time (or try to join a new network), it needs to obtain an IP address to communicate. So it first transmits a DHCPDISCOVER message on its local subnet. Because the client has no way of knowing the subnet to which it belongs, the DHCPDISCOVER is an all-subnets broadcast (destination IP address of, which is a layer 3 broadcast address) and a destination MAC address of FF-FF-FF-FF-FF-FF (which is a layer 2 broadcast address). The client does not have a configured IP address, so the source IP address of is used. The purpose of DHCPDISCOVER message is to try to find out a DHCP Server (a server that can assign IP addresses).


2. After receiving the discover message, the DHCP Server will dynamically pick up an unassigned IP address from its IP pool and broadcast a DHCPOFFER message to the client(*). DHCPOFFER message could contain other information such as subnet mask, default gateway, IP address lease time, and domain name server (DNS).


(*)Note: In fact, the DHCPOFFER is a layer 3 broadcast message (the IP destination is but a layer 2 unicast message (the MAC destination is the MAC of the DHCP Client, not FF-FF-FF-FF-FF-FF). So in some books they may say it is a broadcast or unicast message.

3. If the client accepts the offer, it then broadcasts a DHCPREQUEST message saying it will take this IP address. It is called request message because the client might deny the offer by requesting another IP address. Notice that DHCPREQUEST message is still a broadcast message because the DHCP client has still not received an acknowledged IP. Also a DHCP Client can receive DHCPOFFER messages from other DHCP Servers so sending broadcast DHCPREQUEST message is also a way to inform other offers have been rejected.


4. When the DHCP Server receives the DHCPREQUEST message from the client, the DHCP Server accepts the request by sending the client a unicast DHCPACKNOWLEDGEMENT message (DHCPACK).


In conclusion there are four messages sent between the DHCP Client and DHCP Server: DHCPDISCOVER, DHCPOFFER, DHCPREQUEST and DHCPACKNOWLEDGEMENT. This process are often abbreviated as DORA (for Discover, Offer, Request, Acknowledgement).

After receiving DHCPACKNOWLEDGEMENT, the IP address is leased to the DHCP Client. A client will usually keep the same address by periodically contacting the DHCP server to renew the lease before the lease expires.

If the DHCP Server is not on the same subnet with the DHCP Client, we need to configure the router on the DHCP client side to act as a DHCP Relay Agent so that it can forward DHCP messages between the DHCP Client & DHCP Server. To make a router a DHCP Relay Agent, simply put the “ip helper-address <IP-address-of-DHCP-Server>” command under the interface that receives the DHCP messages from the DHCP Client.


As we know, router does not forward broadcast packets (it drops them instead) so DHCP messages like DHCPDISCOVER message will be dropped. But with the “ip helper-address …” command, the router will accept that broadcast message and cover it into a unicast packet and forward it to the DHCP Server. The destination IP address of the unicast packet is taken from the “ip helper-address …” command.

When a DHCP address conflict occurs

During the IP assignment process, the DHCP Server uses ping to test the availability of an IP before issuing it to the client. If no one replies then the DHCP Server believes that IP has not been allocated and it can safely assign that IP to a client. If someone answers the ping, the DHCP Server records a conflict, the address is then removed from the DHCP pool and it will not be assigned to a client until the administrator resolves the conflict manually.

Configure a DHCP Server on Cisco router

Instead of using a separate computer/server as a DHCP Server, we can save the cost and configure a Cisco router (even a Layer 3 Cisco switch) to work as a DHCP Server. The following example configuration will complete this task:

Configuration Description
Router(config)#ip dhcp pool CLIENTS Create a DHCP Pool named CLIENTS
Router(dhcp-config)#network /24 Specifies the subnet and mask of the DHCP address pool
Router(dhcp-config)#default-router Set the default gateway of the DHCP Clients
Router(dhcp-config)#dns-server Configure a Domain Name Server (DNS)
Router(dhcp-config)#domain-name 9tut.com Configure a domain-name
Router(dhcp-config)#lease 0 12 Duration of the lease (the time during which a client computer can use an assigned IP address). The syntax is “lease {days[hours] [minutes] | infinite}”. In this case the lease is 12 hours. The default is a one-day lease.
Before the lease expires, the client typically needs to renew its address lease assignment with the server
Router(config)# ip dhcp excluded-address The IP range that a DHCP Server should not assign to DHCP Clients. Notice this command is configured under global configuration mode
Comments (20) Comments
Comment pages
1 7 8 9 2425
  1. Anonymous
    September 18th, 2019

    Is Passleader good for exam 210-060 CICD?

  2. Anonymous
    September 23rd, 2019

    Latest dumps please. My exam is very close.

  3. Amin
    September 27th, 2019

    Hi Ebrahem

    can you send me the latest Dump for CCNA?

    thank you so much

    amin.moghim at live.com

  4. jana
    October 5th, 2019

    stop asking for dumps like morons, people posted links to them. gosh, learn english

  5. maoca
    October 7th, 2019

    Kindly would anyone send me 200-125 test dumps to mariolopznet at hotmail.com? thank you in advance.

  6. Moon
    October 9th, 2019

    Please send latest 200-125 dumps to MoonBlood1433 at gmail thank you in advance.

  7. Luis
    October 9th, 2019

    Please send latest 200-125 dumps to ledd64 at gmail thank you

  8. Anonymous
    October 13th, 2019

    pls i took the the CCNS RS 200-125 on 12 OCtober 2019 and failed 692/810. i just discovered this site and i can see lab sim from the exam here. pls ayone should send latest dump for the exam for me (greyhatnaija @ gmail . com) . my retake is 18 Oct 19.

    thank you very much

  9. Gracia Fatima
    October 14th, 2019

    Can anyone please send me latest dumps for CCNA RS 200-125 or any important information. please ( gracinhafatima91 @ gmail.com )

  10. Eugene Loweh
    October 21st, 2019

    Please can someone help me with latest dumps for CCNA routing and switching. I am doing recertification. Please will be glad to receive help – {email not allowed}

  11. k3fr3
    October 25th, 2019

    Please, can anyone give me details on the CCNP at the following points:
    – The different types of CCNP
    – The different programs
    – The cost of exams

  12. LEWAWA
    November 28th, 2019

    I tried those commands but the command “lease” is not recognized why?
    i am using cisco paquet tracer.

  13. Anonymous
    December 25th, 2019

    Does anyone has CCNA 200-301 volume 2 by Todd Lammle ? Would appreciate if you had this and gaive me at olly.fb17 at gmail.

  14. Robinhibiscus604 @gmail.com
    December 30th, 2019

    Hello everyone. Can someone please help by sending me the latest CCNA dump.

  15. Jafar ahmed
    January 12th, 2020

    My exam is january 21, i need new questions 7 which one uploaded this week
    Mamun1989 @gmail. Com
    Please help me it will big help, i dont need dumps i have the all questions only new question 7 i need.

  16. Anonymous
    January 30th, 2020

    Just passed my CCNA Security EXAM. The Dumps helped just a little bit. Watch out for some of the incorrect answers. Read the answer comments before you commit. It’s a lovely day for me for me today!!!

  17. Buddy
    January 31st, 2020

    what are the requirement for new CCNA exam? do we need mandatory training? please help!!!!

  18. Michael jeson
    January 31st, 2020

    I have found here lots of interesting information for my knowledge I need. All the details you provide to us about certification, it was very helpful and useful. Your Blog post provides me very actionable tips. Article is nicely explained and easy to understand. Great job.

  19. Noshair Abbas
    February 9th, 2020

    nakdabbas14 @gmail. com

  20. Diego
    February 19th, 2020

    some info about 200-301 ?

Comment pages
1 7 8 9 2425
Add a Comment