DHCP-server should listen on vif interface inside VRF

Hello community,

vyos version: VyOS 1.5-rolling-202402220022

I´m trying to setup a dhcp-server on my vyos router. Client DHCP request is going in, but vyos DHCP server does not respond.

15:49:17.356971 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 00:50:79:66:68:12 (oui Unknown), length 364

The DHCP-Server should listen to vif (sub-interface) subnet, which is part of a VRF. On main interface eth2 there is no specific config.

show log dhcp server (multitiple times - for every main interface + vif):
Feb 23 15:26:39 kea-dhcp4[25993]: 2024-02-23 15:26:39.549 WARN [kea-dhcp4.dhcpsrv/25993.140134949181888] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface eth2 has no usable IPv4 addresses configured
Feb 23 15:26:39 kea-dhcp4[25993]: 2024-02-23 15:26:39.550 WARN [kea-dhcp4.dhcpsrv/25993.140134949181888] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: Failed to open socket on interface eth2.301, reason: failed to bind fallback socket to address 10.2.66.17, port 67, reason: Cannot assign requested address - is another DHCP server running?

Config example looks like:

set interfaces ethernet eth2 vif 301 address ‘10.2.66.17/28’
set interfaces ethernet eth2 vif 301 vrf ‘internet’

set service dhcp-server hostfile-update
set service dhcp-server shared-network-name Internet-edge1 authoritative
set service dhcp-server shared-network-name Internet-edge1 subnet 10.2.66.16/28 option default-router ‘10.2.66.17’
set service dhcp-server shared-network-name Internet-edge1 subnet 10.2.66.16/28 option domain-name ‘domain.com
set service dhcp-server shared-network-name Internet-edge1 subnet 10.2.66.16/28 option name-server ‘10.2.66.2’
set service dhcp-server shared-network-name Internet-edge1 subnet 10.2.66.16/28 range 0 start ‘10.2.66.18’
set service dhcp-server shared-network-name Internet-edge1 subnet 10.2.66.16/28 range 0 stop ‘10.2.66.18’
set service dhcp-server shared-network-name Internet-edge1 subnet 10.2.66.16/28 subnet-id ‘6616’

Did I miss any required configuration, or is this type of config not supported?

Thank you for your help.

Best regards
Jan

Did you use set vrf bind-to-all command?
Feature already added and tested: ⚓ T4733 Feature Request: dhcp server: add VRF support

Hello n.fort,

thanks for support!

I wasn´t aware of that command. But the behavoir didn´t change after adding it to my configuration. In ⚓ T4733 Feature Request: dhcp server: add VRF support daniil said, that this will not work, but he shared a workaround:

I’m using a workaround. I’m running a process in a script /config/scripts/vyos-postconfig-bootup.script:

ip vrf exec office /usr/sbin/dhcpd -4 -q -user dhcpd -group vyattacfg -pf /run/dhcp-server/office-dhcpd.pid -cf /config/user-data/office-dhcpd.conf -lf /config/office-dhcpd.leases

So I think that office seems to be the VRF. I´ve edited /config/scripts/vyos-postconfig-bootup.script with “sudo vi …”. Added this two lines and reboot my vyos. I think that there is still something wrong, because my DHCP client still don´t get an IP-Address.
ip vrf exec internet /usr/sbin/dhcpd -4 -q -user dhcpd -group vyattacfg -pf /run/dhcp-server/internet-dhcpd.pid -cf /config/user-data/internet-dhcpd.conf -lf /config/internet-dhcpd.leases
ip vrf exec mpls /usr/sbin/dhcpd -4 -q -user dhcpd -group vyattacfg -pf /run/dhcp-server/mpls-dhcpd.pid -cf /config/user-data/mpls-dhcpd.conf -lf /config/mpls-dhcpd.leases

Any idea?

Best regards
Jan