OpenWrt Forum Archive

Topic: Dhcp-script option in dnsmasq to implement a "locator"

The content of this topic has been archived on 5 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

The option --dhcp-script seems to be NOT implemented in the dnsmasq version 2.47 on Kamikaze as it is not doing anything... any clue about this?

Dnsmasq in the manual page about dhcp-script wrote:

-6 --dhcp-script=<path>
    Whenever a new DHCP lease is created, or an old one destroyed, the executable specified by this option is run. <path> must be an absolute pathname, no PATH search occurs. The arguments to the process are "add", "old" or "del", the MAC address of the host, the IP address, and the hostname, if known. "add" means a lease has been created, "del" means it has been destroyed, "old" is a notification of an existing lease when dnsmasq starts or a change to MAC address or hostname of an existing lease (also, lease length or expiry and client-id, if leasefile-ro is set). If the MAC address is from a network type other than ethernet, it will have the network type prepended, eg "06-01:23:45:67:89:ab" for token ring. The process is run as root (assuming that dnsmasq was originally run as root) even if dnsmasq is configured to change UID to an unprivileged user.

As I have several wifi's spread on my organization, it would be great to signal every time certain MAC acquires an IP on the network in order to "locate" a person that moves across the many buildings around. An option like this would allow a program to keep a track of where the smart phone of this person is and ping it periodically to make it a reliable source of position.

I move a lot, and with something like this I could make the asterisk pbx to call me to a nearby phone when I move.

Hi. The dnsmasq daemon still checks for and processes /etc/dnsmasq.conf if it exists, therfore you could create this file with just the single option in it:

dhcp-script=/root/myscript.sh

Did it, does nothing... or I'm doing something wrong

(Last edited by tristangrimaux on 13 Nov 2010, 21:33)

Make sure your script is reachable, executable and usable when executed by "nobody".

This is what I have

root@rev1:~# cat /etc/dnsmasq.conf
dhcp-script=/root/echoer.sh

root@rev1:~# cat /root/echoer.sh
#!/bin/sh
echo "$*" >> /tmp/echoer.log

root@rev1:~# ls -l /root/echoer.sh 
-rwxr-xr-x    1 root     root           40 Nov 13 20:28 /root/echoer.sh

anything else?

(Last edited by tristangrimaux on 13 Nov 2010, 21:32)

Thats indeed odd, it should work this way. Do you see anything in logread?

NOW ITS WORKING!!!! I don't know how... ok... now, I'll get back to that thing... I really don't know what I did to make it work, but now is working.

THANKS A LOT JOW

jow wrote:

Thats indeed odd, it should work this way. Do you see anything in logread?

what is logread??? Ok, now I see, is a wonderfull thing I need to study, looks nice.

(Last edited by tristangrimaux on 13 Nov 2010, 21:38)

Funny thing! Good luck to you!

The discussion might have continued from here.