All DHCPOFFERs I get from dnsmasq have a IP lease time of 2min and it ignores the options to change it.
I have two routers on my network:
- AVM FritzBox 7390 (192.168.0.1)
- VDSL2 Modem
- Base for DECT Phones
- Actual routing to the internet
- Netgear R7000 (running FreshTomato firmware, 192.168.0.2)
- WiFi access point
- DHCP Server
My internal DNS is a Pi-Hole running in a Docker Container on my server. (192.168.0.100)
The DHCP Server that FreshTomato brings is a dnsmasq and I need it to tell new clients the following config:
- IP In range 192.168.0.50 - ...80
- IP Lease Time ~1 day
- Router is the FritzBox (192.168.0.1)
- DNS Servers are Pi-Hole (192.168.0.100) and alternatively the FritzBox (192.168.0.1)
So I put all this info into the R7000's UI and when I save the config the following config file for dnsmasq is generated:
pid-file=/var/run/dnsmasq.pid resolv-file=/etc/resolv.dnsmasq addn-hosts=/etc/dnsmasq dhcp-hostsfile=/etc/dnsmasq expand-hosts min-port=4096 interface=br0 dhcp-range=tag:br0,192.168.0.50,192.168.0.80,255.255.255.0,1440m dhcp-option=tag:br0,3,192.168.0.1 dhcp-lease-max=255 dhcp-authoritative log-queries dhcp-option=6,192.168.0.100,192.168.0.1
Looks valid to me, when I test the DHCP config using this neat little nmap script:
nmap --script broadcast-dhcp-disccover
I get the following answer:
| broadcast-dhcp-discover: | Response 1 of 1: | IP Offered: 192.168.0.71 | DHCP Message Type: DHCPOFFER | Server Identifier: 192.168.0.2 | IP Address Lease Time: 2m00s | Renewal Time Value: 1m00s | Rebinding Time Value: 1m45s | Subnet Mask: 255.255.255.0 | Broadcast Address: 192.168.0.255 | Domain Name Server: 192.168.0.100, 192.168.0.1 |_ Router: 192.168.0.1
Everything is correct except that the IP lease time is only 2 minutes. Some devices (3 Smartphones and 2 Android Tables) in my network don't like that short lease time and loose their WiFi connection every minute.
Does anyone know what I did wrong?
Fun Fact: I just flashed FreshTomato, before that I used DD-WRT which had the exact same problem with dnsmasq.
Edit after a few more tests
I created a small test environment for dnsmasq to test some configurations:
- a Docker Container running dnsmasq
- a second Container running that nmap script in a loop
What I found out is:
When I specify the lease time in the
dhcp-range line, it is simply ignored.
I discoverd that it is possible to set the DHCP options directly via their tags assigned by IANA (https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xml)
When I set the DHCP Lease time with
dhcp-option=51,48h the lease time is changed but the renewal and rebind times aren't.
Setting them with their tags 58 and 59 with
dhcp-option=58,24h # DHCP Renewal (T1) Time dhcp-option=59,42h # DHCP Rebinding (T2) Time
didn't help, since the result I got was:
IP Address Lease Time: 2d00h00m00s Renewal Time Value: 1m00s Rebinding Time Value: 1m45s