How a DHCP Relay Agent and DHCP Relay Server Work:
DHCP Relay Agent
A DHCP relay agent is a network device (often a router or switch) configured to forward DHCP requests from clients on its local subnet to a DHCP server located on a different subnet.
When a DHCP client sends out a broadcast DHCP Discover message to request an IP address, routers by default do not forward broadcasts across subnets. The relay agent intercepts this broadcast and encapsulates it into a unicast message, forwarding it directly to the DHCP server.
The relay agent adds its own IP address (the interface where it received the request) to the "giaddr" (gateway IP address) field in the DHCP packet, so the DHCP server knows which subnet the request originated from.
When the DHCP server responds (with an Offer or ACK), it sends the reply back to the relay agent, which then forwards the response as a broadcast (or unicast, depending on client flags) to the original client on the local subnet.
DHCP Relay Server
The term "DHCP relay server" is sometimes used interchangeably with "DHCP relay agent," but typically refers to the software or service running on a device (like a router or dedicated relay server) that performs the relay function.
The relay server listens for DHCP requests on subnets without a DHCP server, forwards those requests to one or more configured DHCP servers, and ensures responses are delivered back to the correct client.
On versa, here’s a breakdown of how to configure a DHCP relay agent, based on the provided documentation:
Start by configuring a DHCP relay agent profile. This defines the relay agent's behavior.
- Navigate to: Networking > DHCP > Relay > Relay Profiles
- Enter a name and description for the profile.
- Specify the Gateway IP Address — this is the IP address of the LAN interface receiving DHCP requests from clients. If VRRP is enabled, use the VRRP VIP address.
Now configure the relay agent itself.
- Navigate to: Networking > DHCP > Relay > Relay
- Provide a name and description for the relay agent.
- (Optional) Use tags to filter relays.
- Client Identifier
- Client Name
- DHCP Options
- Hardware Address
- Interfaces and Networks
- Source Address: IP address of the source (relay interface)
- Forwarding Address (required): IP address of the DHCP server
- Select the appropriate routing instance to reach the DHCP server
→ Case 1: When we are using vrrp in LAN and we have multiple VLANS, we will use Giaddr as the vrrp IP of the specific Vlan and source address would be the actual source address of the vlan.
For example, here in pcap we see unicast packets coming from VIP 10.122.32.2 to Forwarding address(DHCP server) 10.22.16.20
Relay-Profile-LAN5 {
giaddr 10.122.32.2; ← This would be the VIP IP
upstream-servers-and-relays {
Server-for-LAN5 {
forwarding-address [ 10.22.16.20 10.22.16.21 ];
source-address 10.122.32.3; ← This is the actual address on the VLAN5
fwd-routing-instance IPC05672-LAN1-VRF;
Another example of different Giaddr and source address:
Different Ingress and Egress Interfaces: If the relay agent receives the DHCP Discover from the client on one interface (e.g., a VLAN interface connected to the client subnet) and forwards the relayed DHCP packet to the server using another interface (e.g., a routed or loopback interface), the giaddr will typically be set to the IP address of the client-facing interface (to indicate the client’s subnet), while the source address of the relayed packet will be the IP of the interface used to reach the DHCP server
→ Case 2: Using same Giaddr and Source Address
The gateway address (giaddr) and the source address in a DHCP relay agent profile will be the same when the relay agent uses the same interface IP address both to receive the DHCP request from the client and to forward the relayed packet to the DHCP server. This typically happens in these scenarios:
Single Interface Relay: If the relay agent receives the client’s DHCP broadcast on an interface and also uses that same interface’s IP address to send the relayed DHCP packet to the server, both the giaddr and the source IP address will be identica
Explicit Source Configuration: If the relay agent is explicitly configured to use a specific interface as the source for relayed packets (e.g., using a loopback or the same VLAN interface), that address will appear as both the giaddr and the source IP