Get dnsmasq to forget leases

HI,

i have a OpenWRT router with two ethernet port (one LAN and one WAN). I have configured the DHCP server to have a static lease for a MAC prefix (using wildcard for part of the MAC) and port routing to redirect HTTP traffic to said lease. The goal is to have the ability to plug any device with the correct MAC prefix and be able to access it through the WAN port using the Openwrt router hostname. My issue here is that the leasetime for dnsmasq being 2 minutes minimum, whenever i unplug a device and plug new in the LAN port, it takes 2m before dnsmasq can have the lease free to give the lease to the new device.

I tried two things to get this working without having to wait for two minutes:

  • set the lease file to /dev/null. This does not work since the lease are cached and the file is only used between the service restarts
  • trigger a dnsmasq restart (with lease file to /dev/ull) whenever the LAN port is unplugged, but i cannot get any hotplug event for my interface.

How can i get this working ? The sedonc option of restarting dnsmasq seems viable, but the interface being on a bridge i d'on't know how to get hotplug events.

thanks

That's because the device that asks for the lease should release it before unplugging. Otherwise it will just time out like you experienced.

Have you tried deleting /tmp/dhcp.leases and restarting DNSmasq?

rm /tmp/dhcp.leases
service dnsmasq restart

The IP for the mac doesn’t really matter.
You can set static leases for the mac (of interest) fixed to a specific hostname (many mac can be booked with the same hostname as long as they aren't connected at the same time) and forget about the IP.

When you go to the hostname it should work.

Deleting leases or setting lease file to /dev/null and then restarting dnsmasq works, but i would need this to be automated.

I'm not sure to understand. Iw ould configure the static lease to a specific hostname, and then use the port redirection to this hostname ?

Hi,

i figured how to have the static lease configured for the given hostname (instead of IP) but the port redirection has to be configured with a IP and not a hostname. Any idea no how to configure the port redirection from wan to lan to the given host ?

maybe test with a cron job every minute