DHCP Relay trough GRE-Bridge

Testdate: 2022-07-09
Version: 1.3.1-S1
Upgrade Version: 1.4-rolling-202207090632

This simple structure shows how to configure a DHCP Relay over a GRE Bridge interface.

Topology

The topology has 3 VyOS routers and one client. Between the DHCP Server and the DHCP Relay is a GRE tunnel. The transport VyOS represent a large Network.

Ansible Example topology image

Configuration

First, we configure the transport network and the Tunnel interface.

Transport:

set interfaces ethernet eth1 address '10.0.10.254/24'
set interfaces ethernet eth2 address '10.0.20.254/24'

DHCP-Server

set interfaces ethernet eth1 address '10.0.20.10/24'
set interfaces tunnel tun100 address '172.16.0.1/30'
set interfaces tunnel tun100 encapsulation 'gretap'
set interfaces tunnel tun100 remote '10.0.10.10'
set interfaces tunnel tun100 source-address '10.0.20.10'
set protocols static route 0.0.0.0/0 next-hop 172.16.0.2
set protocols static route 10.0.10.0/24 next-hop 10.0.20.254
set protocols static route 192.168.0.0/24 next-hop 127.16.0.2

DHCP-Relay

set interfaces ethernet eth1 address '10.0.10.10/24'
set interfaces ethernet eth2 address '192.168.0.254/24'
set interfaces tunnel tun100 address '172.16.0.2/30'
set interfaces tunnel tun100 encapsulation 'gretap'
set interfaces tunnel tun100 remote '10.0.20.10'
set interfaces tunnel tun100 source-address '10.0.10.10'
set protocols static route 0.0.0.0/0 next-hop 172.16.0.1
set protocols static route 10.0.20.0/24 next-hop 10.0.10.254

After this, we need the DHCP-Server and Relay configuration. To get a testable result, we just have one IP in the DHCP range. Expand it as you need it.

DHCP-Server

set service dhcp-server listen-address '172.16.0.1'
set service dhcp-server shared-network-name DHCPTun100 authoritative
set service dhcp-server shared-network-name DHCPTun100 subnet 192.168.0.0/24 default-router '192.168.0.254'
set service dhcp-server shared-network-name DHCPTun100 subnet 192.168.0.0/24 range 0 start '192.168.0.30'
set service dhcp-server shared-network-name DHCPTun100 subnet 192.168.0.0/24 range 0 stop '192.168.0.30'

DHCP-Relay

set service dhcp-relay interface 'eth2'
set service dhcp-relay interface 'tun100'

Test the result

Ping the Client from the DHCP Server.

vyos@dhcp-server:~$ ping 192.168.0.30 count 4
PING 192.168.0.30 (192.168.0.30) 56(84) bytes of data.
64 bytes from 192.168.0.30: icmp_seq=1 ttl=63 time=0.939 ms
64 bytes from 192.168.0.30: icmp_seq=2 ttl=63 time=0.869 ms
64 bytes from 192.168.0.30: icmp_seq=3 ttl=63 time=1.33 ms
64 bytes from 192.168.0.30: icmp_seq=4 ttl=63 time=1.22 ms

--- 192.168.0.30 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 7ms
rtt min/avg/max/mdev = 0.869/1.089/1.325/0.190 ms

And show all DHCP Leases

vyos@dhcp-server:~$ show dhcp server leases
IP address    Hardware address    State    Lease start          Lease expiration     Remaining    Pool        Hostname
------------  ------------------  -------  -------------------  -------------------  -----------  ----------  ----------
192.168.0.30  00:50:79:66:68:05   active   2022/07/09 19:31:07  2022/07/10 19:31:07  23:59:17     DHCPTun100  VPCS