Page MenuHomeVyOS Platform

DHCP server listen-address doesn't take effect if the interface is in a VRF
Closed, ResolvedPublicBUG

Description

There was a problem with dhcp-server in listen-address when adding an IP address whose interface has vrf.

vyos@vyos# set service dhcp-server listen-address 10.1.1.1
[edit]
vyos@vyos# commit

listen-address "10.1.1.1" not configured on any interface

[[service dhcp-server]] failed
Commit failed
[edit]
vyos@vyos#

If commit listen-address to the IP address of the interface without vrf, everything is commited.

Configuration:

set interfaces ethernet eth0 address '192.168.122.122/24'
set interfaces ethernet eth1 address '172.16.100.1/24'
set interfaces ethernet eth2 address '10.1.1.1/30'
set interfaces ethernet eth2 vrf 'DHCP'
set protocols static route 10.1.10.0/24 interface eth2 vrf 'DHCP'
set service dhcp-server shared-network-name PROV1 subnet 172.16.100.0/24 default-router '172.16.100.1'
set service dhcp-server shared-network-name PROV1 subnet 172.16.100.0/24 static-mapping PC1 ip-address '172.16.100.2'
set service dhcp-server shared-network-name PROV1 subnet 172.16.100.0/24 static-mapping PC1 mac-address '00:50:79:66:68:00'
set service dhcp-server shared-network-name PROV2 subnet 10.1.10.0/24 default-router '10.1.10.1'
set service dhcp-server shared-network-name PROV2 subnet 10.1.10.0/24 name-server '1.1.1.1'
set service dhcp-server shared-network-name PROV2 subnet 10.1.10.0/24 range 1 start '10.1.10.10'
set service dhcp-server shared-network-name PROV2 subnet 10.1.10.0/24 range 1 stop '10.1.10.20'
set vrf name DHCP protocols static route 10.1.10.0/24 next-hop 10.1.1.2
set vrf name DHCP table '1000'

This problem is on the forum:
https://forum.vyos.io/t/listen-address-not-configured-on-any-interface/9549

Details

Version
VyOS 1.4-rolling-202209260217
Is it a breaking change?
Perfectly compatible
Issue type
Bug (incorrect behavior)

Event Timeline

yeah I had this problem too, also @Viacheslav I think you are right:

for address in (dict_search('listen_address', dhcp) or []):
        if is_addr_assigned(address):          <--- 
            listen_ok = True
def is_addr_assigned(ip_address, vrf=None) -> bool:

It looks to me like that function will return False always if the interface is assigned to a VRF and no VRF name is specified.

It looks like there might be another function you can call before calling is_addr_assigned and it is called has_vrf_configured

https://github.com/vyos/vyos-1x/blob/f5a50135f07ac4ec8ed431a757b9c56e607d2132/python/vyos/validate.py#L268

to get the actual VRF name you have to do essentially what that function does:

...
 tmp = ['interfaces', Section.get_config_path(intf), 'vrf']
    if conf.exists(tmp):
        # then tmp is your vrf name.

also bind-to-all wouldn't work for me either I saw somebody suggested that, EDIT:

that might be another point for this bind-all-interfaces; will it know not to bind both a master and slave interface set? It seemed to me like it was trying to to bind to all interfaces regardless if I specified listen-address, but then if I specified listen-interface it still wouldn't find the address associated with the interface. Either way I'm pretty sure you're right

HollyGurza changed the task status from Open to In progress.Mar 27 2024, 9:01 AM
HollyGurza claimed this task.
dmbaturin renamed this task from Listen-address is not commit if the ip address is on the interface with vrf to DHCP server listen-address doesn't take effect if the interface is in a VRF.May 11 2024, 5:21 PM
dmbaturin removed a project: VyOS 1.5 Circinus.
dmbaturin changed Is it a breaking change? from Unspecified (possibly destroys the router) to Perfectly compatible.
dmbaturin changed Issue type from Unspecified (please specify) to Bug (incorrect behavior).