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.358 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.358/0.358/0.358/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.406 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.406/0.406/0.406/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
Mar 21 17:08:41.515517 osdx systemd-journald[1788]: Runtime Journal (/run/log/journal/861e844a51d845da80ca1ef91808d3be) is 1.8M, max 7.2M, 5.4M free.
Mar 21 17:08:41.518247 osdx systemd-journald[1788]: Received client request to rotate journal, rotating.
Mar 21 17:08:41.518323 osdx systemd-journald[1788]: Vacuuming done, freed 0B of archived journals from /run/log/journal/861e844a51d845da80ca1ef91808d3be.
Mar 21 17:08:41.535642 osdx OSDxCLI[2049]: User 'admin' executed a new command: 'system journal clear'.
Mar 21 17:08:42.548195 osdx osdx-coredump[75115]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Mar 21 17:08:42.565096 osdx OSDxCLI[2049]: User 'admin' executed a new command: 'system coredump delete all'.
Mar 21 17:08:45.870183 osdx OSDxCLI[2049]: User 'admin' entered the configuration menu.
Mar 21 17:08:46.074556 osdx OSDxCLI[2049]: User 'admin' added a new cfg line: 'set interfaces eth0.100 address 10.0.0.1/24'.
Mar 21 17:08:46.203672 osdx OSDxCLI[2049]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network dummy subnet 10.0.0.1/32'.
Mar 21 17:08:46.383553 osdx OSDxCLI[2049]: 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'.
Mar 21 17:08:46.566448 osdx OSDxCLI[2049]: User 'admin' added a new cfg line: 'set protocols static route 0.0.0.0/0 next-hop 10.0.0.2'.
Mar 21 17:08:46.764685 osdx OSDxCLI[2049]: User 'admin' added a new cfg line: 'show working'.
Mar 21 17:08:46.897186 osdx ubnt-cfgd[75139]: inactive
Mar 21 17:08:47.069008 osdx INFO[75153]: FRR daemons did not change
Mar 21 17:08:47.100880 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Mar 21 17:08:47.173599 osdx (udev-worker)[75202]: Network interface NamePolicy= disabled on kernel command line.
Mar 21 17:08:47.409364 osdx systemd[1]: Started dhcpd@main.service - "DHCP Server Service instance main".
Mar 21 17:08:47.412362 osdx cfgd[1473]: [2049]Completed change to active configuration
Mar 21 17:08:47.415026 osdx dhcpd[75270]: Wrote 0 leases to leases file.
Mar 21 17:08:47.430349 osdx OSDxCLI[2049]: User 'admin' committed the configuration.
Mar 21 17:08:47.476520 osdx dhcpd[75270]:
Mar 21 17:08:47.476529 osdx dhcpd[75270]: No subnet declaration for eth0 (no IPv4 addresses).
Mar 21 17:08:47.476533 osdx dhcpd[75270]: ** Ignoring requests on eth0.  If this is not what
Mar 21 17:08:47.476537 osdx dhcpd[75270]:    you want, please write a subnet declaration
Mar 21 17:08:47.476541 osdx dhcpd[75270]:    in your dhcpd.conf file for the network segment
Mar 21 17:08:47.476545 osdx dhcpd[75270]:    to which interface eth0 is attached. **
Mar 21 17:08:47.476549 osdx dhcpd[75270]:
Mar 21 17:08:47.479516 osdx OSDxCLI[2049]: User 'admin' left the configuration menu.
Mar 21 17:08:47.489036 osdx dhcpd[75270]: Server starting service.
Mar 21 17:08:48.695798 osdx dhcpd[75270]: DHCPDISCOVER from de:ad:be:ef:6c:20 via 20.0.0.3
Mar 21 17:08:49.696211 osdx dhcpd[75270]: DHCPOFFER on 20.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 20.0.0.3
Mar 21 17:08:49.697344 osdx dhcpd[75270]: DHCPREQUEST for 20.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:20 (osdx) via 20.0.0.3
Mar 21 17:08:49.721194 osdx dhcpd[75270]: 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.682 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.682/0.682/0.682/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.429 ms

--- 1.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.429/0.429/0.429/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.286 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.286/0.286/0.286/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
Mar 21 17:09:36.771604 osdx dbus-daemon[835]: [system] Successfully activated service 'org.freedesktop.timedate1'
Mar 21 17:09:36.001921 osdx systemd[1]: Started systemd-timedated.service - Time & Date Service.
Mar 21 17:09:36.002425 osdx systemd-journald[1788]: Time jumped backwards, rotating.
Mar 21 17:09:36.004690 osdx systemd-timedated[76107]: Changed local time to Fri 2025-03-21 17:09:36 UTC
Mar 21 17:09:36.007433 osdx OSDxCLI[2049]: User 'admin' executed a new command: 'set date 2025-03-21 17:09:36'.
Mar 21 17:09:36.578867 osdx systemd-journald[1788]: Runtime Journal (/run/log/journal/861e844a51d845da80ca1ef91808d3be) is 1.8M, max 7.2M, 5.4M free.
Mar 21 17:09:36.582440 osdx systemd-journald[1788]: Received client request to rotate journal, rotating.
Mar 21 17:09:36.582568 osdx systemd-journald[1788]: Vacuuming done, freed 0B of archived journals from /run/log/journal/861e844a51d845da80ca1ef91808d3be.
Mar 21 17:09:36.600693 osdx OSDxCLI[2049]: User 'admin' executed a new command: 'system journal clear'.
Mar 21 17:09:37.666759 osdx osdx-coredump[76125]: Deleting all coredumps in /opt/vyatta/etc/config/coredump...
Mar 21 17:09:37.679204 osdx OSDxCLI[2049]: User 'admin' executed a new command: 'system coredump delete all'.
Mar 21 17:09:41.311574 osdx OSDxCLI[2049]: User 'admin' entered the configuration menu.
Mar 21 17:09:41.477938 osdx OSDxCLI[2049]: User 'admin' added a new cfg line: 'set interfaces eth0.100 address 10.0.0.1/24'.
Mar 21 17:09:41.677832 osdx OSDxCLI[2049]: User 'admin' added a new cfg line: 'set service dhcp-server shared-network dummy subnet 10.0.0.1/32'.
Mar 21 17:09:41.801236 osdx OSDxCLI[2049]: 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'.
Mar 21 17:09:41.968300 osdx OSDxCLI[2049]: User 'admin' added a new cfg line: 'set protocols static route 0.0.0.0/0 next-hop 10.0.0.2'.
Mar 21 17:09:42.154733 osdx OSDxCLI[2049]: 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'.
Mar 21 17:09:42.366078 osdx OSDxCLI[2049]: User 'admin' added a new cfg line: 'show working'.
Mar 21 17:09:42.558475 osdx ubnt-cfgd[76150]: inactive
Mar 21 17:09:42.759409 osdx INFO[76166]: FRR daemons did not change
Mar 21 17:09:42.806515 osdx kernel: 8021q: adding VLAN 0 to HW filter on device eth0
Mar 21 17:09:42.862798 osdx (udev-worker)[76214]: Network interface NamePolicy= disabled on kernel command line.
Mar 21 17:09:43.123399 osdx systemd[1]: Started dhcpd@main.service - "DHCP Server Service instance main".
Mar 21 17:09:43.133643 osdx cfgd[1473]: [2049]Completed change to active configuration
Mar 21 17:09:43.150976 osdx dhcpd[76283]: Wrote 0 leases to leases file.
Mar 21 17:09:43.156105 osdx OSDxCLI[2049]: User 'admin' committed the configuration.
Mar 21 17:09:43.207419 osdx OSDxCLI[2049]: User 'admin' left the configuration menu.
Mar 21 17:09:43.216026 osdx dhcpd[76283]:
Mar 21 17:09:43.216435 osdx dhcpd[76283]: No subnet declaration for eth0 (no IPv4 addresses).
Mar 21 17:09:43.216598 osdx dhcpd[76283]: ** Ignoring requests on eth0.  If this is not what
Mar 21 17:09:43.216695 osdx dhcpd[76283]:    you want, please write a subnet declaration
Mar 21 17:09:43.216917 osdx dhcpd[76283]:    in your dhcpd.conf file for the network segment
Mar 21 17:09:43.217015 osdx dhcpd[76283]:    to which interface eth0 is attached. **
Mar 21 17:09:43.217096 osdx dhcpd[76283]:
Mar 21 17:09:43.234608 osdx dhcpd[76283]: Server starting service.
Mar 21 17:09:44.564635 osdx dhcpd[76283]: DHCPDISCOVER from de:ad:be:ef:6c:20 via 20.0.0.2
Mar 21 17:09:44.772177 osdx dhcpd[76283]: DHCPDISCOVER from de:ad:be:ef:6c:20 via 30.0.0.2
Mar 21 17:09:45.564860 osdx dhcpd[76283]: DHCPOFFER on 20.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 20.0.0.2
Mar 21 17:09:45.567871 osdx dhcpd[76283]: DHCPREQUEST for 20.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:20 (osdx) via 20.0.0.2
Mar 21 17:09:45.599254 osdx dhcpd[76283]: DHCPACK on 20.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 20.0.0.2
Mar 21 17:09:45.772470 osdx dhcpd[76283]: DHCPOFFER on 30.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 30.0.0.2
Mar 21 17:09:45.773325 osdx dhcpd[76283]: DHCPREQUEST for 30.0.0.50 (10.0.0.1) from de:ad:be:ef:6c:20 (osdx) via 30.0.0.2
Mar 21 17:09:45.807619 osdx dhcpd[76283]: DHCPACK on 30.0.0.50 to de:ad:be:ef:6c:20 (osdx) via 30.0.0.2