Schedule a free product or technology session with Grandmetric Engineer
schedule a video call

Blog

IP and Mobile Trends and Education

 

What is DHCP and how does it work?

Author:


18.07.2017

DHCP (Dynamic Host Configuration Protocol) is a protocol that is commonly used in networks for dynamic IP addressing configuration. Every user’s device needs at least IP address to join the network and connect to services. When computer first connects to local network with cable or WiFi SSID, first thing is to look for IP address, netmask, default gateway and DNS servers.

How does DHCP work?

  1. Host connecting to network (cable or wireless) sends DHCP discover message to all hosts in Layer 2 segment (destination address is FF:FF:FF:FF:FF:FF). Frame with this DISCOVER message hits the DHCP Server.

 

DHCP Discover packet

2. After the DHCP Server receives discover message it suggests the IP addressing offering to the client host by unicast. This OFFER message contains:

  • proposed IP address for client (here 192.168.1.10)
  • subnet mask to identify the subnet space (here 255.255.255.0)
  • IP of default gateway for subnet (here 192.168.1.1)
  • IP of DNS server for name translations (here 8.8.8.8)
  • Options (read full article)

 

DHCP Offer packet

 

3. Now after the client receives the offer it requests the information officially sending REQUEST message to server this time by unicast.

 

DHCP Request packet

 

 

4. Server sends ACKNOWLEDGE message confirming the DHCP lease to client. Now client is allowed to use new IP settings.

DHCP Acknowledge packet

What information getting from DHCP are necessary and which are optional?

In theory, only IP address and mask is needed for device to work. This is true in scenario that device is within the same subnet with other devices and communicates with others knowing their IP addresses. In such way there is no need for going beyond own subnet and that’s why gateway is not needed. Using only IP addresses for communication also eliminates the need of name translations so DNS is still optional. However, in real world scenarios most of communication goes beyond the subnet and relays on Fully Qualified Domain Names (FQDN).

In addition to necessary DHCP parameters there are DHCP options like popular Option 150 used in IP Telephony to inform IP Phones about the IP address of IP PBX for proper phone registration – for example Cisco Call Manager or Asterisk PBX. Almost all DHCP server vendors are able to pass DHCP options.

 

What if DHCP server is not in the same subnet ?

You can ask yourself if there is a need for having DHCP server in the same L2 segment (VLAN), because DHCP OFFER message relays on broadcast destination address which is good for the same subnet only. Right trace! But for the sake of DHCP scalability there is option to have DHCP server outside the subnet. In such solution DHCP discover packets typically getting to default gateway interface are transformed into unicast packets (DHCP discover embedded message) with giaddr field that tells server about logical attachment identification. Packet is sent directly to IP of server located somewhere in routable IP cloud. Giaddr helps the DHCP server to find the correct address pool for granting the address.

DHCP relay

Check how to configure DHCP server on network device.

 

Author

Marcin Bialy

Marcin Biały is Network and Security Architect with over 12 years of experience, with Service Provider and Enterprise networking background. He used to work for large service providers, global vendors and integration services companies as Network Architect, Leading Architect and Techincal Solution Manager positions. He designed, implemented and supported dozens large scale projects and infrastructure migrations, solved hundreds of tickets and spent hours with CLI and GUI of many flavors. Marcin is also holding industry recognizable certificates such as CCNP, CCNA, CCSI #35269, FCNSP #7207, FCNSA and more.

2 Comments
Alok Rawat
22 April 2019 at 13:44

Thanks a lot brother !! live long

 
Harsh
15 September 2019 at 15:44

Really good article. Especially, the point you have mentioned about Giaddr.

 

Leave a Reply to Alok Rawat Cancel Reply

Your email address will not be published. Required fields are marked *

*

code


 

Newsletter