Page MenuHomeVyOS Platform

show dhcp server leases error for lease time 4294967295
Closed, ResolvedPublicBUG

Description

Where attempting to list leased addresses I get the following error:

$ show dhcp server leases
Traceback (most recent call last):

File "/usr/libexec/vyos/op_mode/dhcp.py", line 286, in <module>
  res = vyos.opmode.run(sys.modules[__name__])
File "/usr/lib/python3/dist-packages/vyos/opmode.py", line 227, in run
  res = func(**args)
File "/usr/libexec/vyos/op_mode/dhcp.py", line 246, in _wrapper
  return func(*args, **kwargs)
File "/usr/libexec/vyos/op_mode/dhcp.py", line 277, in show_server_leases
  lease_data = _get_raw_server_leases(family=family, pool=pool, sorted=sorted, state=state)
File "/usr/libexec/vyos/op_mode/dhcp.py", line 85, in _get_raw_server_leases
  data_lease['end'] = lease.end.timestamp()

AttributeError: 'NoneType' object has no attribute 'timestamp'

Details

Difficulty level
Unknown (require assessment)
Version
VyOS 1.4-rolling-202301290317
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

@Jimz Show please the file cat /config/dhcpd.leases
I cannot reproduce it even if no any leases

vyos@r14:~$ show dhcp server leases 
IP Address    MAC address    State    Lease start    Lease expiration    Remaining    Pool    Hostname
------------  -------------  -------  -------------  ------------------  -----------  ------  ----------
vyos@r14:~$

Is there a way to share it privately? It has some of the internal domains and leases.

I backed up /config/dhcpd.leases - replaced it with an empty file. And it appears to be working, the /config/dhcpd.leases file seems to have been corrupted or malformated.

After the first lease I got the same error:

cat /config/dhcpd.leases

  1. The format of this file is documented in the dhcpd.leases(5) manual page.
  2. This lease file was written by isc-dhcp-4.4.3-P1

authoring-byte-order entry is generated, DO NOT DELETE

authoring-byte-order little-endian;

lease 172.18.4.38 {

starts 5 2023/03/03 02:09:13;
ends never;
tstp never;
cltt 5 2023/03/03 02:09:13;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:15:5d:07:26:00;
uid "\377]\007&\000\000\001\000\001'\237\2437\000\025]kX-";
set shared-networkname = "PROD";
set ClientIp = "172.18.4.38";
set ClientMac = "0:15:5d:7:26:0";
set ClientName = "acme";
set ClientDomain = "acme.com";
client-hostname "acme";
on expiry {
  set ClientName = 
     pick-first-value (host-decl-name, 
                       option fqdn.hostname, 
                       option host-name) ;
  set ClientIp = 
     binary-to-ascii (10, 8, ".", leased-address) ;
  execute ("/usr/libexec/vyos/system/on-dhcp-event.sh", "release", "", ClientIp, "", "");
}
on release {
  set ClientName = 
     pick-first-value (host-decl-name, 
                       option fqdn.hostname, 
                       option host-name) ;
  set ClientIp = 
     binary-to-ascii (10, 8, ".", leased-address) ;
  execute ("/usr/libexec/vyos/system/on-dhcp-event.sh", "release", "", ClientIp, "", "");
}

}
server-duid "\000\001\000\001+\224\016\037\000\025]kX!";

sh dhcp server leases
Traceback (most recent call last):

File "/usr/libexec/vyos/op_mode/dhcp.py", line 286, in <module>
  res = vyos.opmode.run(sys.modules[__name__])
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/vyos/opmode.py", line 227, in run
  res = func(**args)
        ^^^^^^^^^^^^
File "/usr/libexec/vyos/op_mode/dhcp.py", line 246, in _wrapper
  return func(*args, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^
File "/usr/libexec/vyos/op_mode/dhcp.py", line 277, in show_server_leases
  lease_data = _get_raw_server_leases(family=family, pool=pool, sorted=sorted, state=state)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/libexec/vyos/op_mode/dhcp.py", line 85, in _get_raw_server_leases
  data_lease['end'] = lease.end.timestamp()
                      ^^^^^^^^^^^^^^^^^^^

AttributeError: 'NoneType' object has no attribute 'timestamp'

@Jimz Which lease time are you useing?

starts 5 2023/03/03 02:09:13;
ends never;

With default config I see something like

lease 192.0.2.10 {
  starts 5 2023/03/03 08:07:15;
  ends 6 2023/03/04 08:07:15;
...

Is it static mapping?

That is a static reservation. Ensures I have the same IP for a specific host.

Standard lease I have in the configuration is "lease 4294967295"

Possible completions:

<0-4294967295>       DHCP lease time in seconds

It is incompatible with static entries.
Maybe it should be fixed after migrating to KEA-DHCP T3316

Viacheslav renamed this task from show dhcp server leases error to show dhcp server leases error for static entries.Mar 6 2023, 10:24 AM

@Jimz could you share an example of configuration?
I can't reproduce it with

set service dhcp-server shared-network-name Lan01 authoritative
set service dhcp-server shared-network-name Lan01 name-server '1.1.1.1'
set service dhcp-server shared-network-name Lan01 subnet 192.0.2.0/24 default-router '192.0.2.1'
set service dhcp-server shared-network-name Lan01 subnet 192.0.2.0/24 range R1 start '192.0.2.10'
set service dhcp-server shared-network-name Lan01 subnet 192.0.2.0/24 range R1 stop '192.0.2.254'
set service dhcp-server shared-network-name Lan01 subnet 192.0.2.0/24 static-mapping myhost ip-address '192.0.2.5'
set service dhcp-server shared-network-name Lan01 subnet 192.0.2.0/24 static-mapping myhost mac-address '02:a6:0c:88:3e:a2'

Op-mode

vyos@r14# run show dhcp server leases 
IP Address    MAC address        State    Lease start          Lease expiration     Remaining    Pool    Hostname
------------  -----------------  -------  -------------------  -------------------  -----------  ------  ----------
192.0.2.12    ea:5b:87:26:9e:47  active   2023/03/09 15:40:50  2023/03/10 15:40:50  23:58:00     Lan01   r1
192.0.2.13    1a:a2:7a:1a:c9:94  active   2023/03/09 15:40:51  2023/03/10 15:40:51  23:58:01     Lan01   r1
[edit]
vyos@r14#

Client site gets dynamic and static DHCP entries:

peth1            192.0.2.13/24                     u/u  
peth2            192.0.2.12/24                     u/u  
peth3            192.0.2.5/24                      u/u

Leases file

vyos@r14# cat /config/dhcpd.leases
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.4.3-P1

# authoring-byte-order entry is generated, DO NOT DELETE
authoring-byte-order little-endian;

lease 192.0.2.11 {
  starts 5 2023/03/03 08:07:28;
  ends 5 2023/03/03 12:03:59;
  tstp 5 2023/03/03 12:03:59;
  cltt 5 2023/03/03 08:07:28;
  binding state free;
  hardware ethernet 52:54:00:38:cc:4f;
}
lease 192.0.2.10 {
  starts 5 2023/03/03 08:07:15;
  ends 6 2023/03/04 08:07:15;
  tstp 6 2023/03/04 08:07:15;
  cltt 5 2023/03/03 08:07:15;
  binding state free;
  hardware ethernet 52:54:00:c7:31:bc;
  set shared-networkname = "Lan01";
}
server-duid "\000\001\000\001+\234\235RRT\000\3071\274";

lease 192.0.2.12 {
  starts 4 2023/03/09 13:40:50;
  ends 5 2023/03/10 13:40:50;
  cltt 4 2023/03/09 13:40:50;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet ea:5b:87:26:9e:47;
  set shared-networkname = "Lan01";
  client-hostname "r1";
}
lease 192.0.2.13 {
  starts 4 2023/03/09 13:40:51;
  ends 5 2023/03/10 13:40:51;
  cltt 4 2023/03/09 13:40:51;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 1a:a2:7a:1a:c9:94;
  set shared-networkname = "Lan01";
  client-hostname "r1";
}
[edit]
vyos@r14#

Example configuration:

service {

dhcp-server {
    hostfile-update
    shared-network-name NetworkA {
        authoritative
        subnet 172.30.1.0/24 {
            default-router 172.30.1.1
            domain-name acme.com
            domain-search acme.com
            lease 4294967295
            name-server 172.31.4.10
            name-server 172.30.4.10
            ntp-server 172.31.4.10
            ntp-server 172.30.4.10
            range 0 {
                start 172.30.1.30
                stop 172.30.1.200
            }
        }
    }

I was able to get it to work as expected by reducing the lease below 4294967295 and removing the /config/dhcpd.leases file. It should work per the instruction to make the lease effectively static. It had worked in the past so at some point the check that the resultant lease end day is numeric.

Viacheslav renamed this task from show dhcp server leases error for static entries to show dhcp server leases error for lease time 4294967295.Mar 10 2023, 7:12 AM
Viacheslav changed the task status from In progress to Needs testing.Mar 10 2023, 12:02 PM

Will be fixed in the next rolling release

Viacheslav moved this task from Need Triage to Finished on the VyOS 1.4 Sagitta board.