DHCP relay agent configuration example

Created by Srividya Anantapatnaikuni, Modified on Thu, 1 Aug at 6:31 AM by Srividya Anantapatnaikuni

Introduction:

DHCP is a client/server protocol that automatically provides an IP address and other related configuration information such as the subnet mask and default gateway as needed. When a client connects to a network, it sends an IP broadcast packet, visible only within the subnet on which the requester resides, to find the DHCP server. Typically, DHCP servers are centralized and are not present on every subnet.

DHCP Relay provides a way for DHCP clients to communicate with DHCP servers when none are available on its local subnet. The purpose of the DHCP relay is to forward incoming requests from DHCP clients to a DHCP server.  Any time a client's DHCP packet is broadcast, a local DHCP relay will process its request and forward it on to the DHCP server, encapsulating them in a unicast packet.

Example:

Here is a topology in which there is a DHCP client having no IP address. There is a DHCP server having IP address 10.0.1.1 and there is a router in the middle which we want as the DHCP relay agent has an IP address 10.0.1.2 on interface eth0 and 10.1.1.1 on interface eth1.

Configuration:

This is the basic configuration of the DHCP server and relay agent:

DHCP_Server:

set interfaces ethernet eth1 address '10.0.1.1/24'
set service dhcp-server listen-address '10.0.1.1'
set service dhcp-server shared-network-name subnet1 subnet 10.1.1.0/24 default-router '10.1.1.1'
set service dhcp-server shared-network-name subnet1 subnet 10.1.1.0/24 range 0 start '10.1.1.10'
set service dhcp-server shared-network-name subnet1 subnet 10.1.1.0/24 range 0 stop '10.1.1.100'

DHCP_Relay_Agent: 

set interfaces ethernet eth0 address '10.0.1.2/24'
set interfaces ethernet eth1 address '10.1.1.1/24'
set service dhcp-relay listen-interface 'eth1'
set service dhcp-relay relay-options relay-agents-packets 'discard'
set service dhcp-relay server '10.0.1.1'
set service dhcp-relay upstream-interface 'eth0'

Verification:

vyos@vyos:~$ show dhcp server leases
IP Address    MAC address        State    Lease start          Lease expiration     Remaining    Pool     Hostname    Origin
------------  -----------------  -------  -------------------  -------------------  -----------  -------  ----------  --------
10.1.1.10     00:50:79:66:68:0d  active   2024/08/01 06:17:36  2024/08/02 06:17:36  23:50:08     subnet1  VPCS1       local


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article