DHCP relay is introduced to transmit packets between DHCP clients and a DHCP server that are on different network segments. That is, a DHCP relay agent can transparently transmit DHCP broadcast packets between DHCP clients and a DHCP server that are on different network segments.
In practice, the DHCP relay function is generally implemented on a VLANIF interface of a switch. This interface needs to be configured with an IP relay address to specify the DHCP server.
An IP relay address refers to the IP address of the DHCP server specified on the DHCP relay agent. After the DHCP relay function is enabled on an interface, the DHCP broadcast packets received on the interface are sent to the specified server.
Figure 1 shows the process that a DHCP client obtains an address through the DHCP relay agent for the first time.
Figure 1 DHCP client obtaining an address through the DHCP relay agent for the first time

After being initialized, the DHCP client broadcasts a configuration request packet, that is, a DHCP DISCOVER packet, on the local network. If there is no DHCP server on the local network, the device that is enabled with the DHCP relay function and is connected to the local network processes the received broadcast packet and forwards the packet to the corresponding DHCP server on another network.
The DHCP server configures the parameters contained in the received packet and sends the configuration to the DHCP client through the DHCP relay agent.
The DHCP client replies to the DHCP OFFER packet sent by the server by broadcasting a DHCP REQUEST packet through the DHCP relay agent.
The DHCP relay agent sends the DHCP REQUEST packet in unicast mode to the DHCP server.
The DHCP server responds with a unicast DHCP ACK or DHCP NAK packet to the client through the DHCP relay agent.
Figure 2 shows the process that a DHCP client extends the IP address lease through a DHCP relay agent.
Figure 2 DHCP client extending the IP address lease through a DHCP relay agent

After a DHCP client accesses the network for the second time, it only needs to unicast a DHCP REQUEST packet to the DHCP server that has assigned an IP address to the client last time.
The DHCP server then directly returns a unicast DHCP ACK or DHCP NAK packet to the client.
DHCP Relay Agent Supporting VPNs
To forward DHCP packets on a VPN, you need to configure the DHCP relay agent to support VPNs. Once a private route exists, a DHCP REQUEST packet can be sent to the DHCP server to apply for an IP address. The DHCP relay agent sends a DHCP REQUEST packet from the client on a VPN (or on the public network) to the DHCP server on the local VPN, and then sends a DHCP REPLY packet from the server to the client.
Currently, the scenario, CE-PE-PE-CE, is applicable. Both the DHCP server and the client can be deployed on the same CE, or the DHCP server is deployed on a PE while the DHCP client is deployed on a CE.
DHCP Releasing
The DHCP relay agent can send requests to the DHCP server to release the IP addresses that are assigned to DHCP clients. You can run a command on the DHCP relay agent to release the addresses that the DHCP server assigns to DHCP clients in either of the following situations:
The DHCP relay agent, instead of the client, directly sends a request to release the IP address assigned to the client.
The client cannot send a request to the DHCP server to release its IP address.
