Re: [Dnsmasq-discuss] Howto reclaim all dhcp leases after router reboot
Hi, wouldn't it be more proper to fix occasional sync of leases to flash or sdcard? Especially if you reboot your device on your command, I think it should save leases to permanent store and restore it after boot. It is not really dnsmasq specific to create such script. dhcp-leasefile is supposed to be permanently stored. Rewriting in /tmp might be good enough, but it should be synchronized to permanent storage occasionally. It should be done definitely on reboot. DHCP server is the authority, it should not fetch leases from client, but tell them instead. Cheers, Petr On 9/25/20 10:17 AM, Tuxo wrote: > Hi list, > > I'm trying to find better ways to reclaim all active dhcp leases on my > local subnet after my home router running dnsmasq occasionally has to > reboot. > > Usually after a reboot the lease file set with dhcp-leasefile= is empty > and will remain empty until the client renews or rebinds it's lease (T1 > lease and T2 lease time). > > I thought the dhcp-authoritative could be of help here, but that seems > not to be the case for the dhcp-leasefile: it stays empty until the > client does renew or rebind it's lease. > > So my clumsy fix for the matter was a short lease time of 1h to make > sure it would renew the lease after 30 minutes (T1 time) upon my router > reboots. > > I'd like to improve the server configuration, but don't know what else > to try. > > So without further ado here's my /etc/dnsmasq.conf file as it stands: > > listen-address=127.0.0.1 > listen-address=192.168.10.1 > interface=br0 > dhcp-leasefile=/tmp/dnsmasq.leases > dhcp-lease-max=20 > dhcp-range=192.168.10.10,192.168.10.90,255.255.255.0,1h > dhcp-option=3,192.168.10.1 > dhcp-authoritative > log-dhcp > domain=MyDomain > no-resolv > stop-dns-rebind > server=my.dns.provider.ip > > Thanks for some enlightening input ... > > Tuxo > > ___ > Dnsmasq-discuss mailing list > Dnsmasq-discuss@lists.thekelleys.org.uk > http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss > -- Petr Menšík Software Engineer Red Hat, http://www.redhat.com/ email: pemen...@redhat.com PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] Howto reclaim all dhcp leases after router reboot
On Fri, Sep 25, 2020 at 02:39:04PM +0200, Tuxo wrote: > Hi Matus, > > Thanks for replying so quickly to my request. > > On 25.09.20 11:39, Matus UHLAR - fantomas wrote: > > > > > why the need to reclaim them? > > > > Because I like to have a place (file) where I can see what leases have been > given out, to what IP address and what hostname is currently using them. > I've written myself a script to do this for me, independent of what is doing DHCP. It produces output like this:- chris$ lan 16 packets received by filter, 0 packets dropped by kernel 192.168.1.1 2860n xx:xx:xx:xx:xx:xx DrayTek Corp. 192.168.1.3 esprimo xx:xx:xx:xx:xx:xx Fujitsu Technology Solutions GmbH 192.168.1.4 newdnsxx:xx:xx:xx:xx:xx Raspberry Pi Foundation 192.168.1.10TD-W9980 xx:xx:xx:xx:xx:xx TP-LINK TECHNOLOGIES CO.,LTD. 192.168.1.202820n xx:xx:xx:xx:xx:xx DrayTek Corp. 192.168.1.30Tenda-W311R xx:xx:xx:xx:xx:xx Tenda Technology Co., Ltd. 192.168.1.50MC342-AE529C xx:xx:xx:xx:xx:xx Oki Electric Industry Co., Ltd. 192.168.1.92t470 xx:xx:xx:xx:xx:xx Intel Corporate 192.168.1.96humaxYouview xx:xx:xx:xx:xx:xx HUMAX Co., Ltd. 192.168.1.99TL-SG108E xx:xx:xx:xx:xx:xx TP-LINK TECHNOLOGIES CO.,LTD. 192.168.1.107 Galaxy-A10xx:xx:xx:xx:xx:xx Samsung Electronics Co.,Ltd 192.168.1.108 pibackup xx:xx:xx:xx:xx:xx Raspberry Pi Trading Ltd (DUP: 2) 192.168.1.110 amazon-ac95e92de xx:xx:xx:xx:xx:xx Amazon Technologies Inc. 192.168.1.114 oldbackup xx:xx:xx:xx:xx:xx MICRO-STAR INT'L CO.,LTD 192.168.1.121 DESKTOP-978VD5M xx:xx:xx:xx:xx:xx GIGA-BYTE TECHNOLOGY CO.,LTD. It's basically the output from the program arp-scan (available from most repositories I think). -- Chris Green ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] Howto reclaim all dhcp leases after router reboot
Hi Matus, Thanks for replying so quickly to my request. On 25.09.20 11:39, Matus UHLAR - fantomas wrote: why the need to reclaim them? Because I like to have a place (file) where I can see what leases have been given out, to what IP address and what hostname is currently using them. It's all dynamically assigned, so it can change depending on what new devices show up like mobile phones or tablets and what devices have already left - some of them without properly signing off to the router. I simply don't know a better way except monitoring syslog, which is more cumbersome than just checking a single file with all the current leases in it. that's because the lease file is stored in /tmp , which resides on transient filesystem on most routers, The filesystem gets empty and dhcp server has no idea who used what IPs before. Yes, that is true and I indeed completely forgot about that! If I change it back to /var/lib/misc/dnsmasq.leases the file will survive a shutdown. I hope dnsmasq will eventually clean up the "dead" leases from all the devices that forgot to send a proper dhcp release request before the client shuts down. IIRC all my Windows machines and my tablets forget to do it. I assume inactive devices will remain listed until the lease time expires? If not, I end up with an untidy lease file, where most of the entries are no longer actively in use. That would render the file useless. I'll have to check that thoroughly, probably best to keep the lease time short then. Thanks, I guess that solves my issue for now, otherwise I'll report back with new questions. Regards, Tuxo ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] Howto reclaim all dhcp leases after router reboot
On 25.09.20 10:17, Tuxo wrote: I'm trying to find better ways to reclaim all active dhcp leases on my local subnet after my home router running dnsmasq occasionally has to reboot. why the need to reclaim them? Usually after a reboot the lease file set with dhcp-leasefile= is empty and will remain empty until the client renews or rebinds it's lease (T1 lease and T2 lease time). that's because the lease file is stored in /tmp , which resides on transient filesystem on most routers, The filesystem gets empty and dhcp server has no idea who used what IPs before. I thought the dhcp-authoritative could be of help here, but that seems not to be the case for the dhcp-leasefile: it stays empty until the client does renew or rebind it's lease. So my clumsy fix for the matter was a short lease time of 1h to make sure it would renew the lease after 30 minutes (T1 time) upon my router reboots. I'd like to improve the server configuration, but don't know what else to try. I give home machines static IPs (using /etc/ethers and /etc/hosts) outside of dynamic range. That way they aren't in lease file after reboot, but it's much more likely to avoid collisions. So without further ado here's my /etc/dnsmasq.conf file as it stands: listen-address=127.0.0.1 listen-address=192.168.10.1 interface=br0 dhcp-leasefile=/tmp/dnsmasq.leases dhcp-lease-max=20 dhcp-range=192.168.10.10,192.168.10.90,255.255.255.0,1h dhcp-option=3,192.168.10.1 dhcp-authoritative log-dhcp domain=MyDomain no-resolv stop-dns-rebind server=my.dns.provider.ip -- Matus UHLAR - fantomas, uh...@fantomas.sk ; http://www.fantomas.sk/ Warning: I wish NOT to receive e-mail advertising to this address. Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu. My mind is like a steel trap - rusty and illegal in 37 states. ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss