I'm aware the latest verison of dnsmasq doesn't execute the script.
I had a script that detected a new dhcp release and send an email when the MAC address was not in a list.
Do anyone has a script that do something similiar, however not using dhcp-user-script?
#!/bin/sh
# script to detect new dhcp lease
# this will be called by dnsmasq everytime a new device is connected
# with the following arguments
# $1 = add | old
# $2 = mac address
# $3 = ip address
# $4 = device name
known_mac_addr="/etc/known_mac_addr"
notification_email="aaaa@gmail.com"
# check if the mac is in known devices list
grep -q "$2" "$known_mac_addr"
unknown_mac_addr=$?
if [ "$unknown_mac_addr" != 0 ]; then
if [ "$1" == "add" ] ; then
msg="New device on `uci get system.@system[0].hostname`.`uci get dhcp.@dnsmasq[0].domain` $*"
echo `date` $msg >> /root/unknown_macs
# encode colon (:) and send email
sed -i 's/:/-/g' "$msg"
echo -e "From: \nTo:$notification_email \nSubject:DHCP\n\n$msg" | msmtp "$notification_email"
fi
fi
exit 0