New DHCP Client (dnsmasq)

My router is configured to use dnsmasq to provide dhcp. I want to run a script whenever a new client is added to the network for the first time. I'm considering writing a script that monitors the leases file for changes. However, this solution doesn't seem very elegant. Is there a better way?

I guess another option would be to monitor arp.
I could keep a local file with all the known mac addresses (of connected devices).
Then, in my script I could compare the known mac addresses to the arp table (on some regular interval).
If any macs are found in the arp table that aren't in the known mac list then they must be new.
Any better ideas than that?

There are many people currently doing this the same... may be we should unify all snippets and make a unique script...

See dnsmasq option dhcpscript

1 Like

Thanks for the tip. The --dhcp-script parameter is exactly what I needed.

"Shell script to run on DHCP lease creation and destruction."

1 Like