Advertisement
Black_Lava

Bash script show wifi clients on hostapd

Nov 23rd, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.68 KB | None | 0 0
  1. #!/bin/sh
  2. echo "IP address   | MAC address"
  3. for interface in `iw dev | grep Interface | cut -f 2 -s -d" "`
  4. do
  5.   # for each interface, get mac addresses of connected stations/clients
  6.   maclist=`iw dev $interface station dump | grep Station | cut -f 2 -s -d" "`
  7.   # for each mac address in that list...
  8.   for mac in $maclist
  9.   do
  10.         # extract ip from local arp table
  11.         ip=$(arp | grep $mac | awk ' { print $1 } ')
  12.  
  13.         # found an ip tied to the mac address?
  14.         if [ ! -z $ip ]; then
  15.  
  16.             # if found, print in the list
  17.             echo "$ip | $mac"
  18.         else
  19.             echo "Not found into local arp table. Try another way..."
  20.         fi;
  21.   done
  22. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement