Page MenuHomeVyOS Platform

DHCP-Server creation for not primary IP address fails
Closed, ResolvedPublicBUG

Description

Error while declaring more than one IP address on certain interface, and then creating a dhcp-server for one of those IP address (but not for the first declared)
Example:
vyos@vyos# set int eth eth3 address 192.168.200.1/24
vyos@vyos# set int eth eth3 address 10.10.10.1/24
vyos@vyos# commit

vyos@vyos# set service dhcp-server shared-network-name LAN subnet 10.10.10.0/24 default-router 10.10.10.1
vyos@vyos# set service dhcp-server shared-network-name LAN subnet 10.10.10.0/24 dns-server 10.10.10.1
vyos@vyos# set service dhcp-server shared-network-name LAN subnet 10.10.10.0/24 range 0 start 10.10.10.101
vyos@vyos# set service dhcp-server shared-network-name LAN subnet 10.10.10.0/24 range 0 stop 10.10.10.110
vyos@vyos# commit
[ service dhcp-server ]
None of the configured subnets have an appropriate primary IP address on any
broadcast interface configured, nor was there an explicit listen-address
configured for serving DHCP relay packets!

This was tested on:

  • 1.2.7
  • 1.3
  • 1.4

Details

Version
1.2.7 - 1.3 - 1.4
Is it a breaking change?
Perfectly compatible
Issue type
Bug (incorrect behavior)

Event Timeline

@n.fort You can try to replace True with False there (1.3 and 1.4). But it needs more tests. In some cases, it was some bugs with the DHCP server and not the primary address.
https://github.com/vyos/vyos-1x/blob/5d068442cf7b1863724c83168176ce2940a023fe/src/conf_mode/dhcp_server.py#L237

from

if is_subnet_connected(subnet, primary=True)

to

if is_subnet_connected(subnet, primary=False)

At least on simple tests, this modification seems to work.
I have tested on version 1.3, first configuring dhcp server for both addresses: for the one that was defined first, and one for the las IP address defined (of course, one instance of dhcp-server running at a time).
If this needs more testes, let me know what I can do for you.

More tests where done on version 1.3.0-epa1.
First, dhcp_server.py was modified as indicated.

Then:
Interface configs:

vyos@vyos# run show int
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth0             192.168.122.89/24                 u/u  
eth1             -                                 u/D  
eth2             172.16.20.1/24                    u/u  
                 192.168.55.1/24                        
eth3             192.168.200.1/24                  u/u  
                 10.10.10.1/24

Then DHCP server created on interfaces eth2 and eth3:

  • On eth2 -> Created for primary IP address -> Network 172.16.20.0/24
  • On eth3 -> Created for secondary IP address -> Network 10.10.10.0/24
vyos@vyos# run show config comm | grep dhcp
set service dhcp-server shared-network-name LAN subnet 10.10.10.0/24 default-router '10.10.10.1'
set service dhcp-server shared-network-name LAN subnet 10.10.10.0/24 name-server '10.10.10.1'
set service dhcp-server shared-network-name LAN subnet 10.10.10.0/24 range 0 start '10.10.10.101'
set service dhcp-server shared-network-name LAN subnet 10.10.10.0/24 range 0 stop '10.10.10.110'
set service dhcp-server shared-network-name LAN-172 subnet 172.16.20.0/24 default-router '172.16.20.1'
set service dhcp-server shared-network-name LAN-172 subnet 172.16.20.0/24 name-server '172.16.20.1'
set service dhcp-server shared-network-name LAN-172 subnet 172.16.20.0/24 range 0 start '172.16.20.101'
set service dhcp-server shared-network-name LAN-172 subnet 172.16.20.0/24 range 0 stop '172.16.20.110'

Both dhcp servers working as expected, and assigning IP address to clients:

vyos@vyos# run show dhcp server leases 
IP address     Hardware address    State    Lease start          Lease expiration     Remaining    Pool     Hostname
-------------  ------------------  -------  -------------------  -------------------  -----------  -------  ----------
10.10.10.101   00:50:79:66:68:00   active   2021/10/18 14:56:47  2021/10/19 14:56:47  23:38:17     LAN      PC1
172.16.20.101  00:50:79:66:68:01   active   2021/10/18 15:02:08  2021/10/19 15:02:08  23:43:38     LAN-172  PC2

Finally, other virtual PCs where added to topology, to validate that static routing and communications betwen everyhost (dhcp and non dhcp hosts) was OK.
Arp table after some ping tests between differents hosts:

Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.55.2             ether   00:50:79:66:68:02   C                     eth2
172.16.20.101            ether   00:50:79:66:68:01   C                     eth2
172.16.20.2              ether   00:50:79:66:68:03   C                     eth2
10.10.10.101             ether   00:50:79:66:68:00   C                     eth3
10.10.10.2               ether   00:50:79:66:68:04   C                     eth3
192.168.200.2            ether   00:50:79:66:68:05   C                     eth3

Once again, if more tests are needed, please let me know

Other test.
In same lab, pool for LAN subnet was modified:

vyos@DHCP-Server# run show config comm | grep range
set service dhcp-server shared-network-name LAN subnet 10.10.10.0/24 range 0 start '10.10.10.101'
set service dhcp-server shared-network-name LAN subnet 10.10.10.0/24 range 0 stop '10.10.10.103'
set service dhcp-server shared-network-name LAN-172 subnet 172.16.20.0/24 range 0 start '172.16.20.101'
set service dhcp-server shared-network-name LAN-172 subnet 172.16.20.0/24 range 0 stop '172.16.20.110'

Then, used all ip address of the pool, and ensure that next dhcp-client won't get IP from other dhcp-server.

vyos@DHCP-Server# run show dhcp server statistics 
Pool       Size    Leases    Available  Usage
-------  ------  --------  -----------  -------
LAN           3         3            0  100%
LAN-172      10         1            9  10%

vyos@DHCP-Server# run show dhcp server leases 
IP address     Hardware address    State    Lease start          Lease expiration     Remaining    Pool     Hostname
-------------  ------------------  -------  -------------------  -------------------  -----------  -------  ----------
10.10.10.101   00:50:79:66:68:00   active   2021/10/18 14:56:47  2021/10/19 14:56:47  22:10:58     LAN      PC1
10.10.10.102   00:50:79:66:68:08   active   2021/10/18 16:37:47  2021/10/19 16:37:47  23:51:58     LAN      PC5
10.10.10.103   00:50:79:66:68:07   active   2021/10/18 16:37:49  2021/10/19 16:37:49  23:52:00     LAN      PC4
172.16.20.101  00:50:79:66:68:01   active   2021/10/18 15:02:08  2021/10/19 15:02:08  22:16:19     LAN-172  PC2

vyos@DHCP-Server# tail -10 /var/log/messages | grep dhcpd
Oct 18 16:37:46 DHCP-Server dhcpd[2727]: DHCPDISCOVER from 00:50:79:66:68:06 via eth3: network LAN: no free leases
Oct 18 16:37:47 DHCP-Server dhcpd[2727]: DHCPDISCOVER from 00:50:79:66:68:06 via eth3: network LAN: no free leases
Oct 18 16:37:50 DHCP-Server dhcpd[2727]: DHCPDISCOVER from 00:50:79:66:68:06 via eth3: network LAN: no free leases

And output for virtual PC3, that was trying to get ip (this generate previuos "no free leases" log entries in router):

PC3> ip dhcp
DDD
Can't find dhcp server
Viacheslav changed the task status from Open to In progress.Oct 21 2021, 5:36 PM
Viacheslav claimed this task.

PR https://github.com/vyos/vyos-1x/pull/1036

set interfaces ethernet eth1 address '10.100.100.1/24'
set interfaces ethernet eth1 address '192.168.50.1/24'
set service dhcp-server shared-network-name LAN-eth2 subnet 192.168.50.0/24 default-router '192.168.50.1'
set service dhcp-server shared-network-name LAN-eth2 subnet 192.168.50.0/24 name-server '8.8.8.8'
set service dhcp-server shared-network-name LAN-eth2 subnet 192.168.50.0/24 range 0 start '192.168.50.100'
set service dhcp-server shared-network-name LAN-eth2 subnet 192.168.50.0/24 range 0 stop '192.168.50.150'

vyos@r1-roll# commit
[edit]
vyos@r1-roll#

Generated configuration:

vyos@r1-roll# cat /run/dhcp-server/dhcpd.conf 
### Autogenerated by dhcp_server.py ###

# For options please consult the following website:
# https://www.isc.org/wp-content/uploads/2017/08/dhcp43options.html
#
# log-facility local7;


ddns-update-style none;
option rfc3442-static-route code 121 = array of integer 8;
option windows-static-route code 249 = array of integer 8;
option wpad-url code 252 = text;


# Shared network configration(s)
shared-network LAN-eth2 {
    subnet 192.168.50.0 netmask 255.255.255.0 {
        option domain-name-servers 8.8.8.8;
        option routers 192.168.50.1;
        default-lease-time 86400;
        max-lease-time 86400;
        pool {
            range 192.168.50.100 192.168.50.150;
        }
    }
    on commit {
        set shared-networkname = "LAN-eth2";
    }
}
c-po changed the task status from In progress to Needs testing.Oct 21 2021, 5:58 PM
c-po triaged this task as Normal priority.
c-po moved this task from 1.3.0-epa2 to 1.3.0-epa3 on the VyOS 1.3 Equuleus board.
c-po moved this task from Need Triage to Finished on the VyOS 1.3 Equuleus (1.3.0-epa3) board.
c-po moved this task from Open to Finished on the VyOS 1.4 Sagitta board.
c-po set Issue type to Unspecified (please specify).
dmbaturin edited a custom field.
dmbaturin edited a custom field.
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).