Flushing Amahi (dnsmasq) dns cache

The latest version of Amahi uses dnsmasq for network management including dns caching, which works really well. However somehow my Windows 8 laptop’s wifi was enabled at the same time as it’s ethernet LAN connect, and so the laptop ended up with two IP addresses. This is probably due to some bug in Windows 8, but even after I disabled the wifi adaptor, rebooted both my Amahi server and the laptop, the dns cache still retained the now unused IP address for the disabled wifi adapter. In the end I had to manually edit the dnsmasq.leases file in order to fix this – here’s how (as root on on Fedora 21):

1. View your dnsmasq leases to confirm there’s a bogus address you want to remove:

[root@hda-com]# cat /var/lib/dnsmasq/dnsmasq.leases

2. Stop the dnsmasq service

[root@hda-com]# service dnsmasq stop

3. Edit the dnsmasq.leases file to remove the bogus address(s):

[root@hda-com]# nano -w /var/lib/dnsmasq/dnsmasq.leases

2. Start the dnsmasq service

[root@hda-com]# service dnsmasq start

Then renew your client’s IP adress (e.g. using ipconfig /renew on Windows) and you’re done.