(dnsmasq) dhcp-user-script not executed

You can create a hotplug script (in /etc/hotplug.d/dhcp)

[ "$ACTION" == "add" ] || exit 0

known_mac_addr="/etc/known_mac_addr"
notification_email="aaaa@gmail.com"

if ! /bin/grep -iq "$MACADDR" "$known_mac_addr"; then
        msg="IP $IPADDR assigned to a new device with MAC addr $MACADDR"
        echo -e "From: \nTo:$notification_email \nSubject:DHCP\n\n$msg" | msmtp "$notification_email"
fi
exit 0
5 Likes