Definition – DHCP Relay Agent
A DHCP Relay Agent is a network device or software that relays DHCP messages between clients and servers when they are not on the same physical subnet. The relay agent helps in forwarding DHCP requests from clients in one subnet to a DHCP server located in a different subnet, ensuring that the clients can still receive their IP configuration.
How a DHCP Relay Agent Works
- Client Sends DHCP Discover:
- A DHCP client on a subnet sends a DHCP Discover message to locate a DHCP server. This message is broadcasted to the local subnet.
- Relay Agent Receives Discover Message:
- The DHCP Relay Agent, configured on a router or a Layer 3 switch within the subnet, intercepts the broadcasted DHCP Discover message.
- Relay Agent Forwards Message to DHCP Server:
- The relay agent forwards the DHCP Discover message to the DHCP server. It changes the broadcast message to a unicast message and includes its own IP address (known as the Gateway IP Address, or GIADDR) in the DHCP packet. This IP address indicates to the DHCP server which subnet the request originated from.
- DHCP Server Sends Offer:
- The DHCP server receives the Discover message, processes it, and sends back a DHCP Offer message. This message includes an IP address and configuration details suitable for the subnet specified by the GIADDR field.
- Relay Agent Receives Offer:
- The relay agent receives the DHCP Offer message from the DHCP server and forwards it back to the client on the local subnet.
- Client Receives Offer and Sends Request:
- The DHCP client receives the Offer message, selects one of the offers (if multiple were received), and responds with a DHCP Request message, indicating its acceptance of the offer.
- Relay Agent Forwards Request:
- The relay agent forwards the DHCP Request message to the DHCP server.
- DHCP Server Sends Acknowledgment:
- The DHCP server acknowledges the request by sending a DHCP ACK message, which includes the final IP address and configuration details.
- Relay Agent Forwards Acknowledgment:
- The relay agent forwards the DHCP ACK message to the client, completing the DHCP process.
Example Scenario
Network Setup:
- Subnet A: 192.168.1.0/24
- Subnet B: 192.168.2.0/24
- DHCP Server: 192.168.2.10
- DHCP Client: 192.168.1.50
- Router with DHCP Relay Agent: Interfaces on both Subnet A and Subnet B
Steps:
- Client in Subnet A Sends DHCP Discover:
- A client with MAC address 00:11:22:33:44:55 in Subnet A sends a DHCP Discover message.
- Router (Relay Agent) Intercepts Discover:
- The relay agent on the router receives the broadcasted DHCP Discover message on Subnet A (192.168.1.0/24).
- Relay Agent Forwards Discover to DHCP Server:
- The relay agent forwards the Discover message to the DHCP server at 192.168.2.10, adding its own GIADDR (192.168.1.1).
- DHCP Server Sends Offer:
- The DHCP server processes the Discover message and sends a DHCP Offer message to 192.168.1.1, offering an IP address (e.g., 192.168.1.50) and other configuration parameters.
- Relay Agent Forwards Offer to Client:
- The relay agent receives the Offer and forwards it to the client in Subnet A.
- Client Sends DHCP Request:
- The client sends a DHCP Request message to accept the offer.
- Relay Agent Forwards Request to Server:
- The relay agent forwards the Request message to the DHCP server.
- DHCP Server Sends Acknowledgment:
- The server sends a DHCP ACK message to confirm the IP address assignment and configuration.
- Relay Agent Forwards ACK to Client:
- The relay agent forwards the ACK message to the client, completing the process.
Benefits of Using a DHCP Relay Agent
- Centralized DHCP Server Management: Allows a single DHCP server to serve multiple subnets.
- Reduced Administrative Overhead: Simplifies network administration by reducing the need for multiple DHCP servers.
- Scalability: Makes it easier to manage large and complex networks by centralizing DHCP services.
By using a DHCP Relay Agent, networks can efficiently extend DHCP services across multiple subnets without the need for a DHCP server on each subnet, facilitating better management and resource utilization.
Summary
A DHCP Relay Agent is a network device or software that forwards DHCP messages between clients and servers when they are on different subnets. It intercepts DHCP Discover messages from clients, adds its own IP address to indicate the originating subnet, and forwards these messages to the DHCP server. The server responds with configuration details, which the relay agent then sends back to the clients. This allows a single DHCP server to manage IP address assignments across multiple subnets, centralizing administration and improving network scalability.
Useful Links
https://sanchitgurukul.com/basic-networking
