Page MenuHomeVyOS Platform

DHCP Server not listening on interface if interface is not up at start
Open, NormalPublicBUG

Description

Hi!

When an interface comes up after vyos has configured it's DHCP Server, then the DHCP Server does not listen for DHCP requests on that interface. This can easily happen e.g. when a switch is connected to vyos that needs longer to boot than vyos (e.g. after a power outage). Or for interfaces where you have a device connected directly that is not always powered on.

Here is the DHCP server and Interface configuration:

interfaces {
    dummy dum0 {
        address 10.1.0.1/32
    }
    ethernet eth1 {
        address 10.0.0.1/24
        hw-id 00:0d:b9:3c:a4:49
        offload {
            gro
        }
    }
}
service {
    dhcp-server {
        shared-network-name NET1 {
            subnet 10.0.0.0/24 {
                option {
                    default-router 10.0.0.1
                    name-server 9.9.9.9
                    name-server 149.112.112.112
                }
                range 0 {
                    start 10.0.0.100
                    stop 10.0.0.253
                }
                subnet-id 1
            }
        }
    }
}

I have a DHCP server configured for a network on eth1, however eth1 came up late.
Now the DHCP server is only listening on my dummy device:

vyos@vyos:~$ sudo -i ss -ulpn
State     Recv-Q    Send-Q       Local Address:Port        Peer Address:Port    Process                                                                        
 
UNCONN    0         0                  0.0.0.0:4784             0.0.0.0:*        users:(("bfdd",pid=1543,fd=11))                                               
 
UNCONN    0         0                  0.0.0.0:3784             0.0.0.0:*        users:(("bfdd",pid=1543,fd=10))                                               
 
UNCONN    0         0                 10.1.0.1:67               0.0.0.0:*        users:(("kea-dhcp4",pid=2594,fd=15))                                          
 
UNCONN    0         0                  0.0.0.0:123              0.0.0.0:*        users:(("chronyd",pid=2493,fd=7))                                              
UNCONN    0         0                127.0.0.1:323              0.0.0.0:*        users:(("chronyd",pid=2493,fd=5))                                              
UNCONN    0         0                     [::]:4784                [::]:*        users:(("bfdd",pid=1543,fd=13))                                                
UNCONN    0         0                     [::]:3784                [::]:*        users:(("bfdd",pid=1543,fd=12))                                                
UNCONN    0         0                     [::]:3785                [::]:*        users:(("bfdd",pid=1543,fd=15))                                                
UNCONN    0         0                     [::]:123                 [::]:*        users:(("chronyd",pid=2493,fd=8))                                              
UNCONN    0         0                    [::1]:323                 [::]:*        users:(("chronyd",pid=2493,fd=6))                                              
UNCONN    0         0              [::]%pppoe0:546                 [::]:*        users:(("dhcp6c",pid=2547,fd=4))

After restarting KEA it listens on eth1 as well.

vyos@vyos:~$ sudo systemctl restart kea-dhcp4-server
vyos@vyos:~$ sudo -i ss -ulpn
State     Recv-Q    Send-Q       Local Address:Port        Peer Address:Port    Process                                                                         
UNCONN    0         0                  0.0.0.0:4784             0.0.0.0:*        users:(("bfdd",pid=1543,fd=11))                                                
UNCONN    0         0                  0.0.0.0:3784             0.0.0.0:*        users:(("bfdd",pid=1543,fd=10))                                                
UNCONN    0         0                 10.1.0.1:67               0.0.0.0:*        users:(("kea-dhcp4",pid=3416,fd=17))                                           
UNCONN    0         0                 10.0.0.1:67               0.0.0.0:*        users:(("kea-dhcp4",pid=3416,fd=15))                                           
UNCONN    0         0                  0.0.0.0:123              0.0.0.0:*        users:(("chronyd",pid=2493,fd=7))                                              
UNCONN    0         0                127.0.0.1:323              0.0.0.0:*        users:(("chronyd",pid=2493,fd=5))                                              
UNCONN    0         0                     [::]:4784                [::]:*        users:(("bfdd",pid=1543,fd=13))                                                
UNCONN    0         0                     [::]:3784                [::]:*        users:(("bfdd",pid=1543,fd=12))                                                
UNCONN    0         0                     [::]:3785                [::]:*        users:(("bfdd",pid=1543,fd=15))                                                
UNCONN    0         0                     [::]:123                 [::]:*        users:(("chronyd",pid=2493,fd=8))                                              
UNCONN    0         0                    [::1]:323                 [::]:*        users:(("chronyd",pid=2493,fd=6))                                              
UNCONN    0         0              [::]%pppoe0:546                 [::]:*        users:(("dhcp6c",pid=2547,fd=4))

It looks like the DHCP server tries to bind to all interfaces every 5 seconds, but fails on each one that is down (and on pppoe0, however I don't understand why...). After 60 tries it stops:

Mar 01 08:04:09 kea-dhcp4[3416]: 2025-03-01 08:04:09.991 WARN  [kea-dhcp4.dhcpsrv/3416.139743046455808] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: Failed to open socket on interface pppoe0, reason: failed to bind fallback socket to address 94.134.199.121, port 67, reason: Cannot assign requested address - is another DHCP server running?
v/3416.139743046455808] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface eth0 is not running
Mar 01 08:04:15 kea-dhcp4[3416]: 2025-03-01 08:04:15.000 WARN  [kea-dhcp4.dhcpsrv/3416.139743046455808] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface eth2 has no usable IPv4 addresses configured
Mar 01 08:04:15 kea-dhcp4[3416]: 2025-03-01 08:04:15.000 WARN  [kea-dhcp4.dhcpsrv/3416.139743046455808] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface wwan0 is down
Mar 01 08:04:15 kea-dhcp4[3416]: 2025-03-01 08:04:15.000 WARN  [kea-dhcp4.dhcpsrv/3416.139743046455808] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface pim6reg has no usable IPv4 addresses configured
Mar 01 08:04:15 kea-dhcp4[3416]: 2025-03-01 08:04:15.001 WARN  [kea-dhcp4.dhcpsrv/3416.139743046455808] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: Failed to open socket on interface pppoe0, reason: failed to bind fallback socket to address 94.134.199.121, port 67, reason: Cannot assign requested address - is another DHCP server running?
Mar 01 08:04:20 kea-dhcp4[3416]: 2025-03-01 08:04:20.009 WARN  [kea-dhcp4.dhcpsrv/3416.139743046455808] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface eth0 is not running
Mar 01 08:04:20 kea-dhcp4[3416]: 2025-03-01 08:04:20.009 WARN  [kea-dhcp4.dhcpsrv/3416.139743046455808] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface eth2 has no usable IPv4 addresses configured
v/3416.139743046455808] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface wwan0 is down
Mar 01 08:04:20 kea-dhcp4[3416]: 2025-03-01 08:04:20.009 WARN  [kea-dhcp4.dhcpsrv/3416.139743046455808] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface pim6reg has no usable IPv4 addresses configured
Mar 01 08:04:20 kea-dhcp4[3416]: 2025-03-01 08:04:20.010 WARN  [kea-dhcp4.dhcpsrv/3416.139743046455808] DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: Failed to open socket on interface pppoe0, reason: failed to bind fallback socket to address 94.134.199.121, port 67, reason: Cannot assign requested address - is another DHCP server running?
Mar 01 08:04:20 kea-dhcp4[3416]: 2025-03-01 08:04:20.010 INFO  [kea-dhcp4.dhcp4/3416.139743046455808] DHCP4_OPEN_SOCKETS_FAILED maximum number of open service sockets attempts: 60, has been exhausted without success

I think the DHCP server should start, even it interfaces are down/come up and listen properly on an interface once it comes up.

Details

Version
VyOS 1.5-rolling-202502131743
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

It was increased from 5 to 60
https://github.com/vyos/vyos-1x/commit/92631e7516bfe8aebc0332d41c17ba92c93ab7bb

60 times with interval 5 seconds is 300 sec
If after 300 sec the interface is stulll not ready I don’t think that it is a problem of the KEA DHCP

What value do you think better? Fell free to create a PR

Viacheslav triaged this task as Normal priority.Tue, Mar 11, 7:33 AM