English

DHCP Relay

Updated on Aug 22, 2024 by
200

Introduction to DHCP relay

As networks expand and the number of connected devices increases, users within an organization may be distributed across various network segments. Typically, a single DHCP server may face challenges in managing address assignments for multiple segments. To effectively provide IP addresses, the DHCP server needs to send DHCP messages across these different segments.

DHCP Relay

A DHCP relay agent simplifies this process by forwarding DHCP messages between a client and a server located in separate broadcast domains. This capability ensures seamless communication between DHCP clients and servers, even when they are in different broadcast domains.

DHCP Relay Message Format

A DHCP relay agent handles the forwarding of DHCP messages between a DHCP client and a DHCP server, making changes to only specific fields within those messages. The overall format of the messages stays the same.The following fields are modified:

DHCP Relay

Hops:

This field represents the number of DHCP relay agents that a DHCP message has traversed. Initially, a DHCP client or server sets this field to 0. Each time the message passes through a DHCP relay agent, the value increases by 1.

The Hops field serves to limit how many DHCP relay agents a message can pass through, with a maximum of 16 relay agents allowed between a DHCP server and a client. If the field’s value exceeds 16, the DHCP message is discarded.

Giaddr (Gateway IP Address):

This field denotes the IP address of the first DHCP relay agent that the message encounters. When a client sends a DHCP Request message, the first DHCP relay agent fills in its own IP address in this field before forwarding the message to the DHCP server.

The DHCP server uses the Giaddr field to determine the client’s network segment and select an appropriate address pool from which to assign an IP address. The server then sends a DHCP Offer message to the relay agent, which in turn forwards it to the client. If the DHCP Discover message passes through multiple relay agents before reaching the server, the Giaddr field retains the IP address of the initial relay agent. Meanwhile, the Hops field increments by 1 with each relay agent the message passes through.

Working Mechanism of DHCP Relay

The working mechanism of DHCP relay consists of 4 steps:

  • Discovery Phase: When a DHCP client broadcasts a DHCP Discover message, the DHCP relay agent forwards this message to the DHCP server or the next-hop relay agent using unicast, after routing it accordingly.

  • Offer Phase: The DHCP server determines an address pool based on the Giaddr field in the DHCP Discover message and assigns network parameters to the client. Upon receiving the DHCP Offer message, the DHCP relay agent either unicasts or multicasts it to the client.

  • Request Phase: The DHCP relay agent handles the DHCP Request message from the client in the same manner as described in the Discovery Phase.

  • Acknowledgment Phase: The DHCP relay agent processes the DHCP ACK message from the server similarly to how it processes messages in the Offer Phase.

Processing the DHCP Discover Message:

  • The DHCP relay agent first examines the Hops field. If this value exceeds 16, the message is discarded. If not, the Hops value is incremented by 1, and the message proceeds.

  • Next, the relay agent checks the Giaddr field. If this field is set to 0, it updates the Giaddr field with the IP address of the interface that received the DHCP Discover message. If not, it leaves the Giaddr field unchanged and moves on.

  • The relay agent then updates the destination IP address of the DHCP Discover message to that of the DHCP server or the next-hop relay agent, and changes the source IP address to that of the interface connecting the relay agent to the client. The message is then sent via unicast to the designated server or relay agent.

Processing the DHCP Offer Message:

  • Upon receiving the DHCP Offer message, the DHCP relay agent verifies the Giaddr field. If it does not match the IP address of the receiving interface, the message is discarded. If it matches, the agent continues to the next step.

  • The relay agent then checks the Flags field. If this field is set to 1, it broadcasts the DHCP Offer message to the client. If not, it unicasts the DHCP Offer message.

Videos
Global Delivery Service | FS
01:11
Jun 26, 2024
87
Global Delivery Service | FS
Related Topics
Solutions