Simple script to populate hostnames to dumb ap's

Made this small script since I missed client hostnames on my ap.
Needs arp-scan as a dependency. May not work on 19.07 (last time I tried arp-scan was broken there)
Tested on snapshot.
This basically makes a dummy /tmp/dhcp.leases and fills it with entries from the network so that the hostnames are shown in luci
The gateway in the script is hardcoded to so you may have to change this.
You can do the script it in a cronjob and execute it every hour or so to always get up to date names.

arp-scan -l | awk '{print $1" "$2}' | grep 192 | sort -u | sort -k 1 -V > /tmp/list
while read line; do
IP=$(echo $line|awk '{print $1}')
HOSTNAME=$(nslookup $IP | grep name | awk '{print $NF}')
MAC=$(echo $line|awk '{print $2}')
if [ -z "$HOSTNAME" ]
echo "1592624753" $MAC $IP "$HOSTNAME" "*" >> /tmp/dhcp.leases.back
done < /tmp/list
cat /tmp/dhcp.leases.back > /tmp/dhcp.leases
echo "" > /tmp/dhcp.leases.back
1 Like