Last active
January 23, 2018 08:22
-
-
Save Jcpetrucci/445039cfb686124cc785 to your computer and use it in GitHub Desktop.
Unseen DHCP client alert (DD-WRT)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Generates a syslog message w/ prio=emerg for any DHCP client we haven't seen since last reboot. | |
# Note: Syslog server is configured to send SMTP on any event >= emerg. This script alone does not send the mail. | |
echo '#!/bin/sh | |
op="${1:-op}" | |
mac="${2:-mac}" | |
ip="${3:-ip}" | |
hostname="${4}" | |
grep "$mac" /tmp/dnsmasq-leases.log || { export priority=emerg; echo "$mac" "$hostname" >> /tmp/dnsmasq-leases.log; } | |
logger -t "DHCP-Lease" -p ${priority:-info} "${op} ${mac} ${ip} ${hostname}"' > /tmp/dhcp-script.sh | |
chmod +x /tmp/dhcp-script.sh | |
echo 'dhcp-script=/tmp/dhcp-script.sh' >> /tmp/dnsmasq.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment