DHCPv4 relay agent

Hop count in DHCP requests

When a DHCP client broadcasts request, the DHCP relay agent in the switch receives the packets and forwards them to the DHCP server as unicast requests. During this process, the DHCP relay agent increments the hop count before forwarding DHCP packets to the server. The DHCP server, in turn, includes the hop count in the DHCP header in the response sent back to a DHCP client.

DHCP relay option 82

Option 82 is called the relay agent information option. When a DHCP relay agent forwards client-originated DHCP packets to a DHCP server, the option 82 field is inserted/replaced, or the packet with this option is dropped. Servers recognizing the relay agent information option may use the information to implement policies for the assignment of IP addresses and other parameters. The relay agent relays the server-to-client replies to the client.

If a second relay agent is configured to add its own option 82 information, it can encapsulate option 82 information in messages from a first relay agent. The DHCP server uses the option 82 information from both relay agents to decide the IP address for the client..

Inter-VRF DHCP relay

The DHCP relay agent supports anycast gateway using option 82 sub-option 5 (RFC 3527). The DHCP relay discovery packet is filled with the client's gateway IP address in sub-option 5 (discovery packet). The DHCP server uses this information to offer an IP address from the right pool. Pool selection occurs by matching the default gateway configuration settings on the DHCP server with the requested gateway IP address in sub-option 5 in the discovery packet.

The switch uses DHCP relay sub-option 151 to enable DHCP relay to forward discovery and reply packets between VXLAN DHCP clients and DHCP servers even when they are on different overlay or underlay VRFs and the DHCP-server is reachable on the default VRF or one of the overlay VRFs.

In general deployments, a renewal of a DHCP client's IP occurs when the client sends a request to the DHCP server directly. In the case of EVPN VXLAN clients, the DHCP server is not directly reachable. Instead, the renewal request is sent to the DHCP relay. DHCP relay agent fills the option 82 sub-option 11 field in the DHCP discovery packet with the client's gateway IP on the VTEP (which is the relay interface IP address of the VTEP) and the DHCP server returns a DHCP offer reply packet with option 54 set to the DHCP server Identifier. When the reply packet is received by the client, the client uses the IP in option 54 to sent subsequent renewal requests to this IP (VTEP's Relay Interface IP) using sub-option 11 (also known as the Server ID Override Sub-option). Refer to RFC 5107 for more details.

Sub-options 5,11,151,152 are filled in the discover packet, only if a source IP address is defined (using the command ip source-address) for the given DHCP server's source VRF. If the server does not understand sub-option 151, then the server will add sub-option 152 in offer packet.

Configuring a BOOTP/DHCP relay gateway

The DHCP relay agent selects the lowest-numbered IP address on the interface to use for DHCP messages. The DHCP server then uses this IP address when it assigns client addresses. However, this IP address may not be the same subnet as the one on which the client needs the DHCP service. This feature provides a way to configure a gateway address for the DHCP relay agent to use for relayed DHCP requests, rather than the DHCP relay agent automatically assigning the lowest-numbered IP address.