/tmp/dhcp.leases is empty but dhcp clients work

This is a fresh install of openwrt, with zerotier module enabled.

OpenWrt 22.03.5, r20134-5f15225c1e

device is a TPLink Archer c7 v4

  • all network clients are in dhcp mode
  • openwrt is the only dhcp server on the network as evidenced by tcpdump revealing no other offers than from the openwrt router.
  • cat /tmp/dhcp.leases is empty
  • cat /tmp/dhcpd.leases is not empty

the Network > DHCP and DNS > Static Leases page reveals no entries:

How to fix, so that I can make this page show the correct information? is this a known bug?

cat /etc/banner
$ cat /etc/banner
  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 22.03.5, r20134-5f15225c1e
 -----------------------------------------------------
cat /etc/openwrt_release
$ cat /etc/openwrt_release 

DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='22.03.5'
DISTRIB_REVISION='r20134-5f15225c1e'
DISTRIB_TARGET='ath79/generic'
DISTRIB_ARCH='mips_24kc'
DISTRIB_DESCRIPTION='OpenWrt 22.03.5 r20134-5f15225c1e'
DISTRIB_TAINTS=''

cat /etc/device_info
$ cat /etc/device_info 

DEVICE_MANUFACTURER='OpenWrt'
DEVICE_MANUFACTURER_URL='https://openwrt.org/'
DEVICE_PRODUCT='Generic'
DEVICE_REVISION='v0'
uci show dhcp
$ uci show dhcp

dhcp.@dnsmasq[0]=dnsmasq
dhcp.@dnsmasq[0].domainneeded='1'
dhcp.@dnsmasq[0].localise_queries='1'
dhcp.@dnsmasq[0].rebind_protection='1'
dhcp.@dnsmasq[0].rebind_localhost='1'
dhcp.@dnsmasq[0].local='/lan/'
dhcp.@dnsmasq[0].domain='lan'
dhcp.@dnsmasq[0].expandhosts='1'
dhcp.@dnsmasq[0].authoritative='1'
dhcp.@dnsmasq[0].readethers='1'
dhcp.@dnsmasq[0].resolvfile='/tmp/resolv.conf.d/resolv.conf.auto'
dhcp.@dnsmasq[0].localservice='1'
dhcp.@dnsmasq[0].ednspacket_max='1232'
dhcp.@dnsmasq[0].sequential_ip='1'
dhcp.@dnsmasq[0].leasefile='/tmp/dhcp.leases'
dhcp.lan=dhcp
dhcp.lan.interface='lan'
dhcp.lan.start='100'
dhcp.lan.limit='150'
dhcp.lan.leasetime='1h'
dhcp.lan.dhcpv4='server'
dhcp.lan.force='1'
dhcp.lan.dhcpv6='disabled'
dhcp.lan.ra='disabled'
dhcp.wan=dhcp
dhcp.wan.interface='wan'
dhcp.wan.ignore='1'
dhcp.odhcpd=odhcpd
dhcp.odhcpd.maindhcp='0'
dhcp.odhcpd.leasefile='/tmp/hosts/odhcpd'
dhcp.odhcpd.leasetrigger='/usr/sbin/odhcpd-update'
dhcp.odhcpd.loglevel='4'
dhcp.isc_dhcpd=isc_dhcpd
dhcp.isc_dhcpd.authoritative='1'
dhcp.isc_dhcpd.default_lease_time='3600'
dhcp.isc_dhcpd.max_lease_time='86400'
cat /etc/config/network

$ cat /etc/config/network

config interface 'loopback'
	option device 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'fdfc:0b78:d1f4::/48'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'eth0.1'

config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option ip6assign '60'
	option delegate '0'
	option netmask '255.255.0.0'

config device
	option name 'eth0.2'
	option macaddr '50:c7:bf:de:20:5d'

config interface 'wan'
	option device 'eth0.2'
	option proto 'dhcp'

config interface 'wan6'
	option device 'eth0.2'
	option proto 'dhcpv6'

config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '2 3 4 5 0t'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '1 0t'

cat /tmp/dhcpd.leases
$ cat /tmp/dhcpd.leases

lease 192.168.0.117 {
  starts 6 2023/09/02 23:40:14;
  ends 0 2023/09/03 00:40:14;
  cltt 6 2023/09/02 23:40:14;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 58:11:22:a2:fb:ce;
  uid "\001X\021\"\242\373\316";
  client-hostname "brass";
}
lease 192.168.0.119 {
  starts 6 2023/09/02 23:40:15;
  ends 0 2023/09/03 00:40:15;
  cltt 6 2023/09/02 23:40:15;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 9c:b6:d0:f0:29:c1;
  uid "\001\234\266\320\360)\301";
  client-hostname "pennyroyal";
}
lease 192.168.0.110 {
  starts 6 2023/09/02 23:40:15;
  ends 0 2023/09/03 00:40:15;
  cltt 6 2023/09/02 23:40:15;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet b0:e4:d5:ba:83:7c;
  uid "\001\260\344\325\272\203|";
  set vendor-class-identifier = "android-dhcp-12";
}
lease 192.168.0.100 {
  starts 6 2023/09/02 23:40:15;
  ends 0 2023/09/03 00:40:15;
  cltt 6 2023/09/02 23:40:15;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 40:31:3c:64:27:cd;
  client-hostname "chuangmi-ir-v2_miio108706619";
}
lease 192.168.0.101 {
  starts 6 2023/09/02 23:40:16;
  ends 0 2023/09/03 00:40:16;
  cltt 6 2023/09/02 23:40:16;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 7c:49:eb:b1:95:47;
  client-hostname "lumi-gateway-v3_miio98936677";
}
lease 192.168.0.102 {
  starts 6 2023/09/02 23:40:16;
  ends 0 2023/09/03 00:40:16;
  cltt 6 2023/09/02 23:40:16;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 7c:49:eb:25:9a:8c;
  client-hostname "chuangmi-plug-m1_miio88260889";
}
lease 192.168.0.103 {
  starts 6 2023/09/02 23:40:16;
  ends 0 2023/09/03 00:40:16;
  cltt 6 2023/09/02 23:40:16;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 7c:49:eb:22:c7:f9;
  client-hostname "chuangmi-plug-m1_miio88075910";
}
lease 192.168.0.104 {
  starts 6 2023/09/02 23:40:17;
  ends 0 2023/09/03 00:40:17;
  cltt 6 2023/09/02 23:40:17;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 7c:49:eb:22:ea:f2;
  client-hostname "chuangmi-plug-m1_miio88084863";
}
lease 192.168.0.105 {
  starts 6 2023/09/02 23:40:18;
  ends 0 2023/09/03 00:40:18;
  cltt 6 2023/09/02 23:40:18;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 9a:83:c4:06:de:d5;
  set vendor-class-identifier = "udhcp 1.28.3";
}
lease 192.168.0.106 {
  starts 6 2023/09/02 23:40:18;
  ends 0 2023/09/03 00:40:18;
  cltt 6 2023/09/02 23:40:18;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 60:09:c3:b6:85:d5;
  uid "\001`\011\303\266\205\325";
  set vendor-class-identifier = "udhcp 1.22.1";
  client-hostname "SolarInverter";
}
lease 192.168.0.107 {
  starts 6 2023/09/02 23:40:20;
  ends 0 2023/09/03 00:40:20;
  cltt 6 2023/09/02 23:40:20;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet d4:f5:47:17:40:df;
  client-hostname "Google-Nest-Mini";
}
lease 192.168.0.113 {
  starts 6 2023/09/02 23:40:30;
  ends 0 2023/09/03 00:40:30;
  cltt 6 2023/09/02 23:40:30;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 54:b8:0a:ef:e8:fb;
  uid "\001T\270\012\357\350\373";
  client-hostname "pennyroyal";
}
lease 192.168.0.112 {
  starts 6 2023/09/02 23:40:34;
  ends 0 2023/09/03 00:40:34;
  cltt 6 2023/09/02 23:40:34;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet b8:27:eb:5d:a9:d8;
  uid "\001\270'\353]\251\330";
  client-hostname "homeassistant";
}
lease 192.168.0.108 {
  starts 6 2023/09/02 23:41:49;
  ends 0 2023/09/03 00:41:49;
  cltt 6 2023/09/02 23:41:49;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 2a:12:a4:33:8b:18;
  uid "\001*\022\2443\213\030";
  set vendor-class-identifier = "android-dhcp-12";
  client-hostname "Zenobius";
}

Was the router restarted in the hour before you looked at the leases table?

1 Like

Is there a reason you made this a /16? This is not common and not recommended. Usually, a /24 is considered a good size for a home network (255.255.255.0)

I did have that lease time set to 12hrs and had left this running for weeks. during that time, the static leases page remained empty.

recently changed the lease time to 1hr and again left this running like that for a couple of days, still nothing appearing on the static leases page.

but yes, i have been restarting it recently.

I assume you're referring to the fact that the lease file is on a tmpfs ?

yes i want this because: reasons

surely openwrt dhcp server should be able to handle this?

is it a known bug that openwrt dhcp server fails to populate the static leases page unless you use the network mask of /24 ?

Right, by design. So if you restart your router, the leases file goes away. And you have to wait for new leases to be issued (as a function of the existing leases expiring on the client side and the clients requesting a renewal).

1 Like

yep ok, but this cant be the reason because the setup has been running like this for many many many weeks so we can discount me restarting the router as the reason the static lease page is empty

This is almost always unnecessary, but sure... whatever you want. As long as you will never attempt to connect from another network (via the tailscale setup you mentioned) that is in the 192.168.0.0/16 subnet.

Yes, it can, no knwon bugs here.

1 Like

Ok... so what happens if you create a new static lease via the web interface?

1 Like

it gets saved, displayed in the list and remains in the list, and /tmp/dhcp.leases is still empty.

I could be wrong, but it is possible that this only populates for dynamic leases (i.e. static leases don't show up here).

This is hard coded:

Apparently LuCI supports only dnsmasq and odhcpd, but not isc-dhcpd:

2 Likes

most likely. I'm not familar enough with openwrt to know where to look.

One thought I had was that this instance might be using some other software for dhcp and not dnsmasq?

Aha, i did notice something, somewhere mention isc-dhcp.

edit:

$ cat /tmp/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

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

...

how do i make openwrt do what i need ? some kind of opkg dance ?

Each DHCP service has its own lease file, and the format of each file is different.
Since you replaced the DHCP role of dnsmasq, its lease file is now empty.
Someone needs to write the code to make LuCI support isc-dhcpd.

2 Likes

Looking at this with a different lens, @airtonix - there was probably a reason you replaced dnsmasq with isc-dhcpd. With that in mind, for your use-case, is there still a net-positive for this change? If not, go back to dnsmasq; if so, you could put in a feature request for a LuCI app/support for isc (but that may or may not happen anytime soon, if ever, unless you are able to contribute to that effort).

4 Likes

Sorry, I dont remember actually doing this, how could this happen?
I do believe this is a completely fresh install and the only change was installing zerotier for openwrt.

I cant see anywhere on that page where it says something like :

  • remove dnsmasq
  • install some other dhcp thing.

:person_shrugging: ?

So what I'm saying is that if dnsmasq is not setup to be the default dhcp server, then this is a problem with the default state of the install (since I didn't do it).

I guess noone can verify if that is in fact the case and so i guess I'm looking at a reinstall of openwrt on the router with the lastest img on https://openwrt.org/toh/tp-link/archer_c7

But if it turns out that:

  1. upon a fresh install, dnsmasq is not doing dhcp things
    • Then there's a bug.
  2. Or if it's the zerotier pkg doing magical things
    • Then I'll find another way to use zerotier.

My only requirements for dhcp are:

  • able to serve more than 255 nodes. my reason for /16
  • able to automatically resolve node announced hostname under dnsmasq controlled domain name .lan

So i don't think i would have bothered mucking about with removing dnsmasq to achieve that.

ssh'ing into the router to see what is actually running reveals:

root@gateway:~# ps  | grep [dhc]p
    6 root         0 IW<  [mm_percpu_wq]
 2000 root      1308 S    udhcpc -p /var/run/udhcpc-eth0.2.pid -s /lib/netifd/dhcp.script -f -t 0 -i eth0.2 -x

root@gateway:~# ps  | grep dns
 1462 root      2656 S    {dnsmasq} /sbin/ujail -t 5 -n dnsmasq -u -l -r /bin/ubus -r /etc/TZ -r /etc/dnsmasq.
 1516 dnsmasq   1480 S    /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg01411c -k -x /var/run/dnsmasq/dnsmasq.
 5463 root      1308 S    grep dns

root@gateway:~# cat /var/etc/dnsmasq.conf.cfg01411c
# auto-generated config file from /etc/config/dhcp
conf-file=/etc/dnsmasq.conf
dhcp-authoritative
domain-needed
localise-queries
enable-ubus=dnsmasq
expand-hosts
bind-dynamic
local-service
dhcp-sequential-ip
edns-packet-max=1232
domain=lan
local=/lan/
addn-hosts=/tmp/hosts
dhcp-leasefile=/tmp/dhcp.leases
resolv-file=/tmp/resolv.conf.d/resolv.conf.auto
stop-dns-rebind
dhcp-broadcast=tag:needs-broadcast
conf-dir=/tmp/dnsmasq.d
user=dnsmasq
group=dnsmasq


dhcp-ignore-names=tag:dhcp_bogus_hostname
conf-file=/usr/share/dnsmasq/dhcpbogushostname.conf


bogus-priv
conf-file=/usr/share/dnsmasq/rfc6761.conf

So looks to me like i'm using dnsmasq.

Right now you apparently are...
Like you are supposed to.

Your earlier config file extract plus the abnormal dhcp.leases file told us that you were then using the non-standard isc-dhcp.

Although you do not remember it, on the previous time you had probably somehow accidentally installed isc-dhcp. It has never (at least since year 2008) been the default dhcp provider in OpenWrt and has never been included in the default images.

1 Like

Yea

I appreciate the help. But I assue you, that it has been this way since the start. I have not changed anything since i made this thread, nor do i believe I made any kind of replacement of dnsmasq.

If I had, then dnsmasq wouldn not be running, since: it's been like this for the last couple of months.

Any other ideas?