drinkingbird
Part of the Furniture
Noticed while toying with lease times on the two Guest subnets (from Guest Wireless 1) that there seems to be some odd inconsistency with the way DNSMASQ configures subnets and lease times.
For the main LAN, dnsmasq reads several NVRAM variables like dhcp_start, dhcp_end, dhcp_lease and builds dnsmasq.conf from those variables
For the two guest network LANs (lan and lan1) there are nvram variables for lan_lease and lan1_lease set to 1 day, but it seems to not have any impact on dnsmasq. Changing/committing it and restarting dnsmasq has no effect. There are also no start and end IPs specified in NVRAM. So it appears dnsmasq is hardcoded with those two networks and the settings for them rather than being built off NVRAM variables. I guess this is because it can't be configured via the GUI (so not sure why the two lease variables are in NVRAM at all).
dnsmasq.postconf has to be used to modify anything related to those two pools
So for example if you want to change the lease time to 30 days for the main DHCP range you do
nvram set dhcp_lease=2592000
nvram commit
I've found that if this is put in services_start you do not have to restart dnsmasq, it happens before it loads, at least on my router
The lease time does show up correctly in the GUI under DHCP settings (but can't be changed since it exceeds the 7 day max of the gui) and clients do get 30 day leases.
But if you want to change the lease time for the other two ranges, you have to use dnsmasq.postconf script. I changed them both from the default 1 day to 30 days in this example
#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh
sed -i "s/86400s/2592000s/" "$CONFIG"
That changes both ranges to 30 days.
For the heck of it I also used services-start to set the lan_lease and lan1_lease to the same 2592000 just so they match. Doesn't seem to matter but can't hurt.
In theory I could leave NVRAM totally alone and as long as I leave the LAN lease at 1 day in the GUI then the command above would replace all 3. But seemed safer to mimic what it does by default, use NVRAM for the main LAN and modify the file for the other two.
Just a FYI (and a bit of a curiosity as to whether there is any reason for this other than whomever programmed the new guest behavior just did it differently) for anyone else looking to modify those guest ranges and/or change the lease time to more than 7 days on the main LAN.
For the main LAN, dnsmasq reads several NVRAM variables like dhcp_start, dhcp_end, dhcp_lease and builds dnsmasq.conf from those variables
For the two guest network LANs (lan and lan1) there are nvram variables for lan_lease and lan1_lease set to 1 day, but it seems to not have any impact on dnsmasq. Changing/committing it and restarting dnsmasq has no effect. There are also no start and end IPs specified in NVRAM. So it appears dnsmasq is hardcoded with those two networks and the settings for them rather than being built off NVRAM variables. I guess this is because it can't be configured via the GUI (so not sure why the two lease variables are in NVRAM at all).
dnsmasq.postconf has to be used to modify anything related to those two pools
So for example if you want to change the lease time to 30 days for the main DHCP range you do
nvram set dhcp_lease=2592000
nvram commit
I've found that if this is put in services_start you do not have to restart dnsmasq, it happens before it loads, at least on my router
The lease time does show up correctly in the GUI under DHCP settings (but can't be changed since it exceeds the 7 day max of the gui) and clients do get 30 day leases.
But if you want to change the lease time for the other two ranges, you have to use dnsmasq.postconf script. I changed them both from the default 1 day to 30 days in this example
#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh
sed -i "s/86400s/2592000s/" "$CONFIG"
That changes both ranges to 30 days.
For the heck of it I also used services-start to set the lan_lease and lan1_lease to the same 2592000 just so they match. Doesn't seem to matter but can't hurt.
In theory I could leave NVRAM totally alone and as long as I leave the LAN lease at 1 day in the GUI then the command above would replace all 3. But seemed safer to mimic what it does by default, use NVRAM for the main LAN and modify the file for the other two.
Just a FYI (and a bit of a curiosity as to whether there is any reason for this other than whomever programmed the new guest behavior just did it differently) for anyone else looking to modify those guest ranges and/or change the lease time to more than 7 days on the main LAN.
Last edited: