[Dnsmasq-discuss] how to set static arp entry according to dhcp request?

Simon Kelley simon at thekelleys.org.uk
Wed May 26 19:59:07 BST 2010


Darren Hoo wrote:
> Hi  Simon  et all,
> 
> First many thanks to you for this great software.
> 
> I wonder if there is a way in dnsmasq to  set static arp entry
> (not that reading ethers from /etc/ethers).
> let's say one client with a mac address 00:13:02:3a:15:5b send dhcp
> requset and dnsmasq's dhcp server assign ip address 192.168.1.8 to
> this client, then dnsmasq will set up a static  entry in the arp table
> when the dhcp lease is deleted,this static entry will be deleted
> accordingly. I wonder if that's possible.
> 
>  I know that dnsmasq's dbus interface provides  DhcpLeaseAdded,
> DhcpLeaseDeleted,DhcpLeaseUpdated signals which I can use. but
> I wonder there's a simple way without much of coding myself.
> 

You're on the right lines, but much simpler than using DBus is to use
the script which dnsmasq can run when a DHCP lease is created or
destroyed: see --dhcp-script in the dnsmasq man page.


This script gets the IP address and MAC address as arguments and is
executed as root, so a simple shell script to call the arp command
should do what you need.

There are examples of such scripts in contrib/port-forward and
contrib/wrt in the dnsmasq tarball that might help.

HTH


Simon.



More information about the Dnsmasq-discuss mailing list