Home | Reports | Technical Documents | Tech-Blog | One-Shot Gallery | Korea ICT News | Korea Communication Market Data | List of Contributors | Become a Contributor |    
 
 
Section 5G 4G LTE C-RAN/Fronthaul Gigabit Internet IPTV/Video Streaming IoT SDN/NFV Wi-Fi KT SK Telecom LG U+ Network Protocol Samsung   Korean Vendors
 
Real World Private 5G Cases   4 Deployment Models On-Premise Cases 5G Core Control Plane Sharing Cases

5G Core Sharing Cases

   
 
Private 5G Deployment   • Private 5G Frequency Allocation Status in Korea  South Korean government's regulations on private 5G and KT's strategy for entering the market
Cases in Korea   Private 5G Operators |   SK Networks Service (SI) Sejong Telecom (Wire-line Carrier) KT MOS (Affiliate of KT) • Newgens (SI) • NAVER Cloud more >>  
    Enterprise DIY |   Korea Hydro & Nuclear Power (Power Plant) Korea Electric Power Corporation (Energy) • Republic of Korea Navy more >>
 
CHANNELS     HFR Private 5G Solution (my5G)       my5G Solution Components       my5G Key Features        my5G Resources        my5G News          
 
banner
banner
Understanding DHCP Relay Agents
November 05, 2013 | By Netmanias (tech@netmanias.com)
Online viewer:
Comments (37)
22
SUMMARY
This document is the third in our DHCP technical documents series and explains the basic operations of a DHCP relay agent. It covers the procedures of IP address allocation/lease, IP address renewal and IP address release using a DHCP relay agent when a device and a DHCP server are located in different subnets. It also describes how the parameters of DHCP messages are replaced by a DHCP relay agent during such procedures.

 

   

  Table of Contents  

  I. Overview
  II. Why are DHCP Relay Agents Needed in DHCP Operations ?
  III. Basic Operation of DHCP Relay Agents
  Appendix - Format of DHCP Messages in a Network with DHCP Relay Agents

 

 

I. Overview

 

This document provides a technical understanding of a DHCP relay agent that is required in a multi-subnet environment where a DHCP client and a DHCP server reside in different subnets. Chapter II explains why these DHCP relay agents are needed in DHCP operations. Chapter III describes the basic principles of DHCP operations using a DHCP relay agent. Finally, in Appendix, specific message parameters used by DHCP relay agents in each DHCP procedure will be presented.

 

Before you read this document it is recommended that you refer to the companion documents, “Understanding the Basic Operations of DHCP” [2] and “Understanding the Detailed Operations of DHCP” [3].

 

II. Why are DHCP Relay Agents Needed in DHCP Operations?

 

Generally, DHCP messages are broadcasted. So, in order for the messages to be exchanged between a DHCP client (PC) and DHCP server, both the client and server have to reside on the same subnet. That is because routers do not forward any broadcast IP packet (i.e. one with a destination MAC address of FF:FF:FF:FF:FF:FF and a destination IP address of 255.255.255.255) to other interfaces. Thus a broadcast DHCP packet sent by a DHCP client cannot be delivered to DHCP server(s) on different subnet(s) through a router (shown in Figure 1 - (a)). This restriction requires all individual subnets have its own DHCP server for DHCP operation, which is practically not feasible in network operators' networks or corporate computer networks (too many DHCP servers are required in the network!).

 

To address this problem, the concept of a DHCP relay agent has long been adopted [1]. As shown in Figure 1 - (b), enabling the DHCP relay agent function in the router allows DHCP messages to be exchanged between a DHCP client and DHCP server residing on different subnets.1 The core function of this DHCP relay agent is to convert a broadcast DHCP packet into a unicast one, and forward it to a DHCP server.

 

Figure 1. Comparison of DHCP operations between networks with and without a DHCP relay agent

Figure 1. Comparison of DHCP operations between networks with and without a DHCP relay agent

 

III. Basic Operations of DHCP Relay Agents

 

This chapter describes how a PC (e.g. PC1) on “1.1.1.0/24” subnet, as shown in Figure 1 - (b), can communicate with the DHCP server using a DHCP relay agent for all DHCP operations, such as IP address allocation/lease, IP address renewal and IP address release.

 

3.1 IP Address Allocation/Lease Procedure  

 

The DHCP relay agent is located between a PC and DHCP server as shown in Figure 2. The DHCP relay agent receives DHCP Discover and Request messages broadcasted by the PC, and unicasts them directly to the DHCP server. At this point, the DHCP relay agent stores its IP address (the interface address at which it received the DHCP Discover/Request messages) in the “Relay Agent IP (=Gateway IP=giaddr)” field of the DHCP message to be relayed.

 

The DHCP server unicasts a DHCP Offer/Ack message, with the destination IP address set as the relay agent IP address, to the DHCP relay agent. The DHCP relay agent, after checking the “Broadcast Flag” field of the received message, replaces the destination IP address with the IP address of the PC (Broadcast Flag=0) or with the broadcast IP address (Broadcast Flag=1) depending on the “Broadcast Flag” value. It also replaces the source IP address with the IP address of the DHCP relay agent, and forwards the modified message to the PC.

 

Figure 2. IP address allocation/lease procedure in the network with a DHCP relay agent

Figure 2. IP address allocation/lease procedure in the network with a DHCP relay agent

 

1. DHCP Discover

As described in the references [2], “Understanding the Basic Operations of DHCP”, and [3], “Understanding the Detailed Operations of DHCP”, a DHCP client broadcasts a DHCP Discover message on the physical Ethernet subnet to discover all DHCP servers available on the subnet. Upon receiving packets that have a UDP destination port set to 67 (DHCP Discover/Request), a DHCP relay agent replaces the values in the fields of the packets as follows, and then unicasts the modified message to a DHCP server:

  • Destination MAC address: The broadcast MAC address sent by the PC is replaced with the DHCP server MAC address (m5).
  • Source MAC address: The PC MAC address (m1) is replaced with the uplink MAC address of the DHCP relay agent (m3).
  • Destination IP address: The broadcast IP address (255.255.255.255) sent by the PC is replaced with the DHCP server IP address (100.1.1.1).
  • Source IP address: The IP address sent by the PC (0.0.0.0) is replaced with the uplink IP address of the DHCP relay agent (100.1.1.254).
  • Relay Agent IP address: The IP address sent by the PC (0.0.0.0) is replaced with the downlink IP address of the DHCP relay agent (1.1.1.254), the IP address of the relay agent’s interface at which the DHCP Discover message was received.

2. DHCP Offer  

The DHCP server, by referring to the relay agent IP address (giaddr) in a DHCP Discover message, selects an IP address to allocate to the DHCP client from an IP pool, and sends a DHCP Offer message with the destination IP address set as the relay agent IP address2. The DHCP relay agent, when receiving the message, replaces the values in the fields of the packets as follows, and then sends the modified message on to the DHCP client (PC):

  • Destination MAC address: If the “Broadcast Flag” field of the DHCP Offer message sent by a DHCP server is 0 (zero), the DHCP relay agent replaces the value in this field with the PC MAC address (Client MAC field: m1), and unicasts the message. However, if the “Broadcast Flag” value is 1 (one), the relay agent replaces it with the broadcast MAC address (FF:FF:FF:FF:FF:FF), and broadcasts the message.
  • Source MAC address: The DHCP server MAC address (m5) is replaced with the downlink MAC address of the DHCP relay agent (m2).
  • Destination IP address: The DHCP server sends the DHCP Offer message, with the destination address set as the relay agent IP address in the DHCP Discover message (1.1.1.254), to a DHCP relay agent. If the “Broadcast Flag” value in the message is 0, the relay agent replaces the value with the IP address allocated to the PC (Your IP field: 1.1.1.10) for unicasting. However, if the “Broadcast Flag” value is 1, the relay agent replaces it with the broadcast IP address (255.255.255.255) for broadcasting.
  • Source IP address: The DHCP server IP address (100.1.1.1) is replaced with the downlink IP address of the DHCP relay agent (1.1.1.254).

3. DHCP Request

The DHCP client (PC) which received the DHCP Offer message broadcasts a DHCP Request message on the physical Ethernet subnet to request network information data such as IP addresses. The DHCP relay agent, upon receiving this message, replaces the values in the fields (same as in the DHCP Discover message) of the packets as follows, and then unicasts the message to the DHCP server:

  • Destination MAC address: The broadcast MAC address sent by the PC is replaced with the DHCP server MAC address (m5).
  • Source MAC address: The PC MAC address (m1) is replaced with the uplink MAC address of the DHCP relay agent (m3).
  • Destination IP address: The broadcast IP address (255.255.255.255) sent by the PC is replaced with the DHCP server IP address (100.1.1.1).
  • Source IP address: The IP address sent by the PC (0.0.0.0) is replaced with the uplink IP address of the DHCP relay agent (100.1.1.254)
  • Relay Agent IP address: The IP address sent by the PC (0.0.0.0) is replaced with the downlink IP address of the DHCP relay agent (1.1.1.254), the IP address of the relay agent’s interface at which the DHCP Discover message was received.

4. DHCP Ack

The DHCP server sends a DHCP Ack message with the destination IP address set as the relay agent IP address (giaddr)3. The DHCP relay agent, upon receiving this message, replaces the values in the fields of the packets as follows, and then unicasts the message to the DHCP client (PC):

  • Destination MAC address: If the “Broadcast Flag” field of the DHCP Ack message sent by the DHCP server is 0 (zero), the DHCP relay agent replaces the value in this field with the PC MAC address (Client MAC field: m1), and unicasts the message. However, if the “Broadcast Flag” value is 1 (one), the relay agent replaces it with the broadcast MAC address (FF:FF:FF:FF:FF:FF), and broadcasts the message.
  • Source MAC address: The DHCP server MAC address (m5) is replaced with the downlink MAC address of the DHCP relay agent (m2).
  • Destination IP address: The DHCP server sends the DHCP Ack message, with the destination address set as the relay agent IP address in the DHCP Request message (1.1.1.254), to a DHCP relay agent. If the “Broadcast Flag” value in the message is 0, the relay agent replaces the value with the IP address allocated to the PC (Your IP field: 1.1.1.10) for unicasting. However, if the “Broadcast Flag” value is 1, the relay agent replaces it with the broadcast IP address (255.255.255.255) for broadcasting.
  • Source IP address: The DHCP server IP address (100.1.1.1) is replaced with the downlink IP address of the DHCP relay agent (1.1.1.254).

3.2 IP Address Renewal Procedure

 

According to the reference [1], a DHCP client (PC) keeps/stores the DHCP server IP address acquired through a DHCP Ack message (in the DHCP Server Identifier field) during the IP address allocation procedure. Then, if it needs to use the IP address beyond the lease duration, it sends a DHCP Request message to the DHCP server, through unicasting, not broadcasting. And the DHCP server, in respond to the message, unicasts a DHCP Ack message to the DHCP client.

 

As such, in case DHCP messages are to be unicasted, the DHCP relay agent does not need to play its role (of converting a broadcast message to a unicast one) for DHCP operations. So, as can be seen in Figure 3, the DHCP relay agent is not involved in any DHCP operations during the IP address renewal procedure.

 

Figure 3. IP address renewal procedure in the network with a DHCP relay agent

Figure 3. IP address renewal procedure in the network with a DHCP relay agent

 

1. DHCP Request

The DHCP client (PC) unicasts a DHCP Request message with the destination IP address set as the IP address of a DHCP server. Thus, a DHCP relay agent does not receive this message. In other words, no field of the DHCP Request message is replaced by the DHCP relay agent during the IP address renewal procedure.

 

2. DHCP Ack

The DHCP server unicasts a DHCP Ack message with the destination IP address set as the IP address of the DHCP client (PC). Again, a DHCP relay agent does not receive this message. In other words, no field of the DHCP Ack message is replaced by the DHCP relay agent during the IP address renewal procedure.

 

3.3 IP Address Release Procedure

 

According to the reference [1], RFC 1542, when an IP address is released, a DHCP client (PC) unicasts a DHCP Release message to a DHCP server directly. Thus, a DHCP relay agent is not involved in the IP address release procedure as shown in Figure 4.

 

Figure 4. IP address release procedure in the network with a DHCP relay agent

Figure 4. IP address release procedure in the network with a DHCP relay agent

 

1. DHCP Release

A DHCP client unicasts a DHCP Release message with the destination IP address set as the IP address of a DHCP server. Thus a DHCP relay agent does not receive this message. In other words, no fields of the DHCP Ack message is replaced by the DHCP relay agent during the IP address release procedure.

 

References

 

[1] W. Wimer, “Clarifications and Extensions for the Bootstrap Protocol”, RFC 1542, Standard, October 1993.

[2] Netmanias Technical Document, “Understanding the Basic Operations of DHCP”, October 2013

[3] Netmanias Technical Document, “Understanding the Detailed Operations of DHCP”, October 2013 

 

Footnotes

 

1 Generally, routers and L3 switches support all of DHCP relay agent functions.

2 Unless the IP address of a DHCP relay agent is set as “0.0.0.0”, a DHCP server always unicasts a DHCP Offer message to the DHCP relay agent regardless of the Broadcast Flag value.

3 Unless the IP address of a DHCP relay agent is set as “0.0.0.0”, a DHCP server always unicasts a DHCP Ack message to the DHCP relay agent regardless of the Broadcast Flag value.

 

Appendix Format of DHCP Messages in a Network with DHCP Relay Agents

 

This appendix provides specific examples of DHCP message parameters that are replaced by a DHCP relay agent during DHCP procedures. However, in case of IP address renewal and release procedures, a DHCP relay agent does NOT replace any part of DHCP messages. Thus, all messages related to those procedures are excluded in this appendix. 

 

DHCP Discover Message

 

Figure 5. DHCP Discover message in IP address allocation/lease procedure

Figure 5. DHCP Discover message in IP address allocation/lease procedure

 

Ethernet Header

  • Destination MAC Address: The Broadcast MAC address (0xFFFFFFFFFFFF) is replaced with the DHCP server MAC address (m5).
  • Source MAC Address: The PC MAC address (m1) is replaced with the uplink MAC address of the DHCP relay agent (m3).

IP Header

  • Source IP Address: The IP address (0.0.0.0) is replaced with the uplink IP address of the DHCP relay agent (100.1.1.254).
  • Destination IP Address: The broadcast IP address (255.255.255.255) is replaced with the DHCP server IP address (100.1.1.1).

DHCP Message Payload

  • Gateway IP Address (giaddr): The IP address (0.0.0.0) is replaced with the downlink IP address of the DHCP relay agent (1.1.1.254) that receives a DHCP Discover message from PC.

DHCP Offer Message

 

Figure 6. DHCP Offer message in IP address allocation/lease procedure

Figure 6. DHCP Offer message in IP address allocation/lease procedure

 

Ethernet Header

  • Destination MAC Address: The uplink MAC address of the DHCP relay agent (m3) is replaced with the broadcast MAC address (0xFFFFFFFFFFFF).

Note: In this example, as we assumed that the “Broadcast Flag” value is set to 1, the relay agent broadcasts the message.  

  • Source MAC Address: The DHCP server MAC address (m5) is replaced with the downlink MAC address of the DHCP relay agent (m2).

IP Header

  • Source IP Address: The DHCP server IP address (100.1.1.1) is replaced with the downlink IP address of the DHCP relay agent (1.1.1.254).
  • Destination IP Address: The downlink IP address of the DHCP relay agent (giaddr=1.1.1.254) is replaced with the broadcast IP address (255.255.255.255).

Note: In this example, as we assumed that the “Broadcast Flag” value is set to 1, the relay agent broadcasts the message.  

 

DHCP Request Message

 

Figure 7. DHCP Request message in IP address allocation/lease procedure

Figure 7. DHCP Request message in IP address allocation/lease procedure

 

Ethernet Header

  • Destination MAC Address: The broadcast MAC address (0xFFFFFFFFFFFF) is replaced with the DHCP server MAC address (m5).
  • Source MAC Address: The PC MAC address (m1) is replaced with the uplink MAC address of the DHCP relay agent (m3).

IP Header

  • Source IP Address: The IP address (0.0.0.0) is replaced with the uplink IP address of the DHCP relay agent (100.1.1.254).
  • Destination IP Address: The broadcast IP address (255.255.255.255) is replaced with the DHCP server IP address (100.1.1.1).

DHCP Message Payload

  • Gateway IP Address (giaddr): The IP address (0.0.0.0) is replaced with the downlink IP address of the DHCP relay agent (1.1.1.254) that receives a DHCP Request message from PC.

DHCP Ack Message

 

Figure 8. DHCP Ack message in IP address allocation/lease procedure

Figure 8. DHCP Ack message in IP address allocation/lease procedure

 

Ethernet Header

  • Destination MAC Address: The uplink MAC address of the DHCP relay agent is replaced with the broadcast MAC address (0xFFFFFFFFFFFF).
  • Note: In this example, as we assumed that the “Broadcast Flag” is set to 1, the relay agent broadcasts the message.  
  • Source MAC Address: The DHCP server MAC address (m5) is replaced with the downlink MAC address of the DHCP relay agent (m2).

IP Header

  • Source IP Address: The DHCP server IP address (100.1.1.1) is replaced with the downlink IP address of the DHCP relay agent (1.1.1.254).
  • Destination IP Address: The downlink IP address of the DHCP relay agent (giaddr=1.1.1.254) is replaced with the broadcast IP address (255.255.255.255).

Note: In this example, as we assumed that the “Broadcast Flag” value is set to 1, the relay agent broadcasts the message.  

 

 

 

varun chaudhary 2017-07-26 14:49:18

Awesome article. Haven't seen such a detailed and clear discription of the topic.

Netmanias 2017-07-26 16:43:31

Hi Varun, Thank you for your compliment :-)

rakesh 2017-10-30 03:48:30

super details thanks a  lot for a great article...

vikram 2017-12-08 16:43:04

I ever r seen this much clear explanatioin on dhcp relay agent. Thank you :)

Priyanshu 2017-12-11 20:30:00

This is by far the best explanation i have seen on DHCP.. thank a ton !!!

Jim 2018-03-28 10:59:25

Best article written on DHCP to the date.

Chris Changmo Yoo 2018-03-28 12:17:12

Thank you for your compliment. I'm glad you liked it. 

ranji 2018-06-05 05:57:58

excellent!!! a crystal clear explanation with enormous details... verymuch appreciated... hats off...

megs 2018-06-16 11:37:07

Wonderful article !! Thanks for the insight, it's been helpful in understanding DHCP

Muriel 2018-10-03 03:03:38

The document is pretty helpful! Thanks for sharing such an enormous details article.

Liju Philip 2018-11-09 18:59:01

Excellent document. Very useful.Thanks for sharing

Adel 2018-12-26 07:20:14

good explanation Thanks

Igor 2019-02-05 01:05:34

Very, very gooood. Big Thanks !!!

benjadavid 2019-03-30 03:40:31

omg! this is super work.

ron 2019-04-09 18:29:26

the best i ever seen

 

thanks !!

jtac 2019-05-14 19:53:01

you did a well job but smothing you need to edit in relp port it should be 67

 

victor balraj 2019-05-17 18:33:20

wonderful article...Really appriciated..Great Thanks...

Ajith Adapa 2019-07-16 01:28:10

Excellent Article.

 

Is it possible to know which editing tool you have used to draw such a beautiful detailed explanaions with respect to protocol ?

Chris Yoo 2019-07-24 08:23:49

We mainly use Microsoft Visio as a drawing tool.

Srini 2019-10-11 13:46:32

How does the the relay agent know the DHCP server IP and MAC?

chris 2019-10-15 11:35:32

The DHCP server IP should be configured on relay agent,

but MAC address of the DHCP server does not need to be known by the relay agent.

said 2020-05-22 11:01:57

The source port and destination port used between router and DHCP server must be 67 in both direction.

Vidhun 2020-06-18 15:42:15

Nice work, this gives a good explanation. 

Akhil 2020-06-30 03:16:37

Very informative article !! A quick note though, I think the source port from the relay agent should be 67 itself otherthan 68 whent the relay agent unicasts the packets to the Server. Correct me if i am wrong.

Akhil 2020-06-30 03:18:33

narayanpethabhilash@gmail.com 2020-07-10 13:15:10

Very useful article on DHCP relay agent 

spidy_trench 2020-07-17 16:12:56

I've been surfing internet to get packet level explaination specifially with DHCP Server located on a different network, this is the best explaination I have ever came across.

 

- Great Job.  I can imagine your efforts and time behind this.

 

Cheers from Seattle, USA

Massimiliano Sbaraglia 2021-01-24 21:52:12

It is possible to havce the same good lesson about DHCPv6 messages and if it possible understand better the transport between an client with DHCPv6 request over an IPv4 network backbone; the DHCP server is dual-stack ? Thank you too much

max@massimilianosbaraglia.it

Rajneesh Panwar 2021-02-26 13:41:13

Very well explained and easiest way with artifacts.

 

"GOOD WORK"

san 2021-03-25 03:53:44

Wow supper ....

rbhati 2021-05-21 19:23:54

Vice nice explanation.

 

Can we configure any device except (router/switch) as DHCP relay agent?

If  yes, then can we configure one port as DHCP client and other port as DHCP relay agent on this device (this device neither  a router nor a switch)?  

rmanedi 2022-02-08 06:23:04

wonderful explination

Safal 2022-05-27 12:30:40

Was looking for information on how DHCP identifies it came from which subnet? Nice Explaination. Thanks for taking time and efforts.

rahul 2023-05-25 17:02:24

really nice content

Carlos 2023-11-30 16:12:36

Hi, The DHCPDISCOVER and DHCPREQUEST packets used as SIP the IP: 1.1.1.254, not the 100.1.1.254

 

 

Ali 2024-03-04 20:48:12

Hi , If between Router (DHCP Relay) and DHCP Server , there is a Firewall , does it work?

In this case , Does the client Get IP address?

Ali 2024-03-04 20:54:16

Hi , If between Router (DHCP Relay) and DHCP Server , there is a Firewall , does it work?

In this case , Does the client Get IP address?

Thank you for visiting Netmanias! Please leave your comment if you have a question or suggestion.
Related Contents
11/07/2013
Netmanias Technical Documents
10/30/2013
Netmanias Technical Documents
10/23/2013
Netmanias Technical Documents
08/01/2013
Netmanias Blog
07/01/2013
Netmanias Blog
 
 
 
 

[HFR Private 5G: my5G]

 

Details >>

 

 

 

     
         
     

 

     
     

Subscribe FREE >>

Currently, 55,000+ subscribed to Netmanias.

  • You can get Netmanias Newsletter

  • You can view all netmanias' contents

  • You can download all netmanias'

    contents in pdf file

     
     

 

     
         
     

 

 

 

View All (181)
5G (9) 6G (1) Backbone (2) Backhaul (3) Blockchain (1) CDN (1) Carrier Ethernet (3) Charging (1) Cloud Native (1) Core (1) DHCP (4) ECM (2) EMM (16) EPS (2) Google (1) HLS (1) HTTP Adaptive Streaming (3) Handover (5) IPTV (4) Initial Attach (2) IoT (2) Korea (1) LTE (39) LTE Identification (2) LTE-A (1) MPLS (2) Mobility (2) NAT (7) Netflix (1) Network Architecture (3) Network Protocol (20) New Radio (1) OTT (1) PCRF (3) Private 5G (1) QoS (3) RCS (3) SDF (2) SDN/NFV (3) SK Telecom (2) Samsung (3) Security (5) Sk Telecom (1) Transparent Cache (1) Video Streaming (4) VoLTE (2) Wi-Fi (1) YouTube (2)
Password confirmation
Please enter your registered comment password.
Password