Relay

This scenario shows how to configure service dhcp-relay. The relay agent must be used when the DHCP server and the DHCP clients are not connected to the same layer 2 domain.

../../../_images/toplogy.svg

Test DHCP Relay

Description

This example demonstrates how to configure a DHCP relay instance in DUT0 to forward DHCP requests from DUT2 to DUT1.

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces ethernet eth0 vif 100 address 10.0.0.2/24
set interfaces ethernet eth1 vif 200 address 20.0.0.2/24
set service dhcp-relay INS downstream-interface eth1.200
set service dhcp-relay INS server 10.0.0.1
set service dhcp-relay INS upstream-interface eth0.100
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 vif 100 address 10.0.0.1/24
set protocols static route 0.0.0.0/0 next-hop 10.0.0.2
set service dhcp-server shared-network dummy subnet 10.0.0.1/32
set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth0 vif 200 address dhcp
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 4: Ping IP address 10.0.0.1 from DUT0:

admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1
Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.219 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.219/0.219/0.219/0.000 ms

Step 5: Run command interfaces ethernet show at DUT2 and check if output contains the following tokens:

20.0.0.50
Show output
---------------------------------------------------------------------
  Name             IP Address           Admin  Oper  Vrf  Description
---------------------------------------------------------------------
    eth0  fe80::dcad:beff:feef:6c20/64  up     up
eth0.200  20.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c20/64
    eth1                                down   down

Test DHCP Relay With Giaddr

Description

This example demonstrates how to set the gateway IP address (giaddr) in the IP address. This value must be set in an IP address that the DHCP server can reach.

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces ethernet eth0 vif 100 address 10.0.0.2/24
set interfaces ethernet eth1 vif 200 address 20.0.0.2/24
set interfaces ethernet eth1 vif 200 address 20.0.0.3/24
set service dhcp-relay INS downstream-interface eth1.200
set service dhcp-relay INS server 10.0.0.1 giaddr 20.0.0.3
set service dhcp-relay INS upstream-interface eth0.100
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 vif 100 address 10.0.0.1/24
set protocols static route 0.0.0.0/0 next-hop 10.0.0.2
set service dhcp-server shared-network dummy subnet 10.0.0.1/32
set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth0 vif 200 address dhcp
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 4: Ping IP address 10.0.0.1 from DUT0:

admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1
Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.228 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.228/0.228/0.228/0.000 ms

Step 5: Run command interfaces ethernet show at DUT2 and check if output contains the following tokens:

20.0.0.50
Show output
---------------------------------------------------------------------
  Name             IP Address           Admin  Oper  Vrf  Description
---------------------------------------------------------------------
    eth0  fe80::dcad:beff:feef:6c20/64  up     up
eth0.200  20.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c20/64
    eth1                                down   down

Step 6: Run command system journal show | cat at DUT1 and check if output matches the following regular expressions:

DHCPACK on 20.0.0.50 to [^\)]+\) via 20.0.0.3
Show output
May 26 11:26:59.000183 osdx systemd-timedated[130830]: Changed local time to Mon 2025-05-26 11:26:59 UTC
May 26 11:26:59.001247 osdx systemd-journald[1729]: Time jumped backwards, rotating.
May 26 11:26:59.002347 osdx OSDxCLI[112949]: User 'admin' executed a new command: 'set date 2025-05-26 11:26:59'.
May 26 11:26:59.316752 osdx systemd-journald[1729]: Runtime Journal (/run/log/journal/ba2ceb2530374437ab3721223a91688e) is 1020.0K, max 7.2M, 6.2M free.
May 26 11:26:59.317242 osdx systemd-journald[1729]: Received client request to rotate journal, rotating.
May 26 11:26:59.317281 osdx systemd-journald[1729]: Vacuuming done, freed 0B of archived journals from /run/log/journal/ba2ceb2530374437ab3721223a91688e.
May 26 11:26:59.327778 osdx OSDxCLI[112949]: User 'admin' executed a new command: 'system journal clear'.
May 26 11:26:59.800519 osdx osdx-coredump[132317]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
May 26 11:26:59.811051 osdx OSDxCLI[112949]: User 'admin' executed a new command: 'system coredump delete all'.
May 26 11:27:01.578092 osdx OSDxCLI[112949]: User 'admin' entered the configuration menu.
May 26 11:27:01.713191 osdx OSDxCLI[112949]: User 'admin' added a new cfg line: 'set interfaces eth0.100 address 10.0.0.1/24'.
May 26 11:27:01.776691 osdx OSDxCLI[112949]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network dummy subnet 10.0.0.1/32'.
May 26 11:27:01.889462 osdx OSDxCLI[112949]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50'.
May 26 11:27:01.950366 osdx OSDxCLI[112949]: User 'admin' added a new cfg line: 'set protocols static route 0.0.0.0/0 next-hop 10.0.0.2'.
May 26 11:27:02.080914 osdx OSDxCLI[112949]: User 'admin' added a new cfg line: 'show working'.
May 26 11:27:02.160580 osdx INFO[132344]: FRR daemons did not change
May 26 11:27:02.181241 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
May 26 11:27:02.210153 osdx (udev-worker)[132395]: Network interface NamePolicy= disabled on kernel command line.
May 26 11:27:02.357673 osdx systemd[1]: Started dhcpd@main.service - "DHCP Server Service instance main".
May 26 11:27:02.360139 osdx cfgd[1437]: [112949]Completed change to active configuration
May 26 11:27:02.361164 osdx dhcpd[132417]: Wrote 0 leases to leases file.
May 26 11:27:02.381333 osdx dhcpd[132417]:
May 26 11:27:02.381475 osdx dhcpd[132417]: No subnet declaration for eth0 (no IPv4 addresses).
May 26 11:27:02.381511 osdx dhcpd[132417]: ** Ignoring requests on eth0.  If this is not what
May 26 11:27:02.381551 osdx dhcpd[132417]:    you want, please write a subnet declaration
May 26 11:27:02.381582 osdx dhcpd[132417]:    in your dhcpd.conf file for the network segment
May 26 11:27:02.381612 osdx dhcpd[132417]:    to which interface eth0 is attached. **
May 26 11:27:02.381640 osdx dhcpd[132417]:
May 26 11:27:02.388201 osdx OSDxCLI[112949]: User 'admin' committed the configuration.
May 26 11:27:02.397385 osdx dhcpd[132417]: Server starting service.
May 26 11:27:02.407055 osdx OSDxCLI[112949]: User 'admin' left the configuration menu.
May 26 11:27:03.037440 osdx dhcpd[132417]: DHCPDISCOVER from de:ad:be:ef:6c:20 via 20.0.0.3
May 26 11:27:04.037585 osdx dhcpd[132417]: DHCPOFFER on 20.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 20.0.0.3
May 26 11:27:04.038131 osdx dhcpd[132417]: DHCPREQUEST for 20.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:20 (osdx) via 20.0.0.3
May 26 11:27:04.066573 osdx dhcpd[132417]: DHCPACK on 20.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 20.0.0.3

Test DHCP Relay With GRE Tunnel

Description

This example demonstrates how to configure a DHCP relay that forwards DHCP requests to the DHCP server through a GRE tunnel (upstream).

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces ethernet eth0 vif 100 address 10.0.0.2/24
set interfaces ethernet eth1 vif 200 address 20.0.0.2/24
set interfaces tunnel tun1 address 1.0.0.2/32
set interfaces tunnel tun1 encapsulation gre
set interfaces tunnel tun1 local-address 10.0.0.2
set interfaces tunnel tun1 local-interface eth0.100
set interfaces tunnel tun1 nhrp holdtime 5
set interfaces tunnel tun1 nhrp nhs 1.0.0.1 nbma 10.0.0.1
set service dhcp-relay INS downstream-interface eth1.200
set service dhcp-relay INS server 1.0.0.1
set service dhcp-relay INS upstream-interface eth0.100
set service dhcp-relay INS upstream-interface tun1
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 vif 100 address 10.0.0.1/24
set interfaces tunnel tun1 address 1.0.0.1/32
set interfaces tunnel tun1 encapsulation gre
set interfaces tunnel tun1 local-address 10.0.0.1
set interfaces tunnel tun1 local-interface eth0.100
set interfaces tunnel tun1 nhrp
set protocols static route 0.0.0.0/0 next-hop 10.0.0.2
set protocols static route 20.0.0.0/24 next-hop 1.0.0.2
set service dhcp-server shared-network dummy subnet 1.0.0.1/32
set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth0 vif 200 address dhcp
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 4: Ping IP address 10.0.0.1 from DUT0:

admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1
Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.225 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.225/0.225/0.225/0.000 ms

Step 5: Ping IP address 1.0.0.1 from DUT0:

admin@DUT0$ ping 1.0.0.1 count 1 size 56 timeout 1
Show output
PING 1.0.0.1 (1.0.0.1) 56(84) bytes of data.
64 bytes from 1.0.0.1: icmp_seq=1 ttl=64 time=0.281 ms

--- 1.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.281/0.281/0.281/0.000 ms

Step 6: Run command interfaces ethernet show at DUT2 and check if output contains the following tokens:

20.0.0.50
Show output
---------------------------------------------------------------------
  Name             IP Address           Admin  Oper  Vrf  Description
---------------------------------------------------------------------
    eth0  fe80::dcad:beff:feef:6c20/64  up     up
eth0.200  20.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c20/64
    eth1                                down   down

Test DHCP Relay With Multiple Instances

Description

This example demonstrates how to configure multiple DHCP relay instances.

Scenario

Step 1: Set the following configuration in DUT0 :

set interfaces ethernet eth0 vif 100 address 10.0.0.2/24
set interfaces ethernet eth1 vif 200 address 20.0.0.2/24
set interfaces ethernet eth1 vif 300 address 30.0.0.2/24
set service dhcp-relay INS downstream-interface eth1.200
set service dhcp-relay INS server 10.0.0.1
set service dhcp-relay INS upstream-interface eth0.100
set service dhcp-relay INS2 downstream-interface eth1.300
set service dhcp-relay INS2 server 10.0.0.1
set service dhcp-relay INS2 upstream-interface eth0.100
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 2: Set the following configuration in DUT1 :

set interfaces ethernet eth0 vif 100 address 10.0.0.1/24
set protocols static route 0.0.0.0/0 next-hop 10.0.0.2
set service dhcp-server shared-network dummy subnet 10.0.0.1/32
set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50
set service dhcp-server shared-network remote2 subnet 30.0.0.0/24 start 30.0.0.50 stop 30.0.0.50
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 3: Set the following configuration in DUT2 :

set interfaces ethernet eth0 vif 200 address dhcp
set interfaces ethernet eth0 vif 300 address dhcp
set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'

Step 4: Ping IP address 10.0.0.1 from DUT0:

admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1
Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.224 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.224/0.224/0.224/0.000 ms

Step 5: Run command interfaces ethernet show at DUT2 and check if output contains the following tokens:

20.0.0.50
Show output
---------------------------------------------------------------------
  Name             IP Address           Admin  Oper  Vrf  Description
---------------------------------------------------------------------
    eth0  fe80::dcad:beff:feef:6c20/64  up     up
eth0.200  20.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c20/64
eth0.300  30.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c20/64
    eth1                                down   down

Step 6: Run command interfaces ethernet show at DUT2 and check if output contains the following tokens:

30.0.0.50
Show output
---------------------------------------------------------------------
  Name             IP Address           Admin  Oper  Vrf  Description
---------------------------------------------------------------------
    eth0  fe80::dcad:beff:feef:6c20/64  up     up
eth0.200  20.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c20/64
eth0.300  30.0.0.50/24                  up     up
          fe80::dcad:beff:feef:6c20/64
    eth1                                down   down

Step 7: Run command system journal show | cat at DUT1 and check if output matches the following regular expressions:

DHCPACK on 20.0.0.50 to [^\)]+\) via 20.0.0.2
DHCPACK on 30.0.0.50 to [^\)]+\) via 30.0.0.2
Show output
May 26 11:27:27.275029 osdx systemd-journald[1729]: Runtime Journal (/run/log/journal/ba2ceb2530374437ab3721223a91688e) is 1.0M, max 7.2M, 6.1M free.
May 26 11:27:27.278544 osdx systemd-journald[1729]: Received client request to rotate journal, rotating.
May 26 11:27:27.278605 osdx systemd-journald[1729]: Vacuuming done, freed 0B of archived journals from /run/log/journal/ba2ceb2530374437ab3721223a91688e.
May 26 11:27:27.285378 osdx OSDxCLI[112949]: User 'admin' executed a new command: 'system journal clear'.
May 26 11:27:27.749095 osdx osdx-coredump[132995]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
May 26 11:27:27.758425 osdx OSDxCLI[112949]: User 'admin' executed a new command: 'system coredump delete all'.
May 26 11:27:29.555832 osdx OSDxCLI[112949]: User 'admin' entered the configuration menu.
May 26 11:27:29.638792 osdx OSDxCLI[112949]: User 'admin' added a new cfg line: 'set interfaces eth0.100 address 10.0.0.1/24'.
May 26 11:27:29.724730 osdx OSDxCLI[112949]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network dummy subnet 10.0.0.1/32'.
May 26 11:27:29.787485 osdx OSDxCLI[112949]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network remote subnet 20.0.0.0/24 start 20.0.0.50 stop 20.0.0.50'.
May 26 11:27:29.882044 osdx OSDxCLI[112949]: User 'admin' added a new cfg line: 'set protocols static route 0.0.0.0/0 next-hop 10.0.0.2'.
May 26 11:27:29.944213 osdx OSDxCLI[112949]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network remote2 subnet 30.0.0.0/24 start 30.0.0.50 stop 30.0.0.50'.
May 26 11:27:30.072602 osdx OSDxCLI[112949]: User 'admin' added a new cfg line: 'show working'.
May 26 11:27:30.159081 osdx INFO[133022]: FRR daemons did not change
May 26 11:27:30.178561 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
May 26 11:27:30.204659 osdx (udev-worker)[133074]: Network interface NamePolicy= disabled on kernel command line.
May 26 11:27:30.323183 osdx systemd[1]: Started dhcpd@main.service - "DHCP Server Service instance main".
May 26 11:27:30.326074 osdx cfgd[1437]: [112949]Completed change to active configuration
May 26 11:27:30.326286 osdx dhcpd[133095]: Wrote 0 leases to leases file.
May 26 11:27:30.352469 osdx OSDxCLI[112949]: User 'admin' committed the configuration.
May 26 11:27:30.367062 osdx dhcpd[133095]:
May 26 11:27:30.367069 osdx dhcpd[133095]: No subnet declaration for eth0 (no IPv4 addresses).
May 26 11:27:30.367072 osdx dhcpd[133095]: ** Ignoring requests on eth0.  If this is not what
May 26 11:27:30.367075 osdx dhcpd[133095]:    you want, please write a subnet declaration
May 26 11:27:30.367077 osdx dhcpd[133095]:    in your dhcpd.conf file for the network segment
May 26 11:27:30.367079 osdx dhcpd[133095]:    to which interface eth0 is attached. **
May 26 11:27:30.367081 osdx dhcpd[133095]:
May 26 11:27:30.376922 osdx OSDxCLI[112949]: User 'admin' left the configuration menu.
May 26 11:27:30.382714 osdx dhcpd[133095]: Server starting service.
May 26 11:27:31.182747 osdx dhcpd[133095]: DHCPDISCOVER from de:ad:be:ef:6c:20 via 20.0.0.2
May 26 11:27:31.346512 osdx dhcpd[133095]: DHCPDISCOVER from de:ad:be:ef:6c:20 via 30.0.0.2
May 26 11:27:32.182901 osdx dhcpd[133095]: DHCPOFFER on 20.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 20.0.0.2
May 26 11:27:32.183554 osdx dhcpd[133095]: DHCPREQUEST for 20.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:20 (osdx) via 20.0.0.2
May 26 11:27:32.207998 osdx dhcpd[133095]: DHCPACK on 20.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 20.0.0.2
May 26 11:27:32.346802 osdx dhcpd[133095]: DHCPOFFER on 30.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 30.0.0.2
May 26 11:27:32.347361 osdx dhcpd[133095]: DHCPREQUEST for 30.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:20 (osdx) via 30.0.0.2
May 26 11:27:32.383909 osdx dhcpd[133095]: DHCPACK on 30.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 30.0.0.2