Script examples

From DD-WRT Wiki

Revision as of 08:14, 9 February 2006 by 209.66.124.150 (Talk)
Jump to: navigation, search

Which IPs and hostnames are used for wireless clients?

Note: Only work if you get an IP from DHCP

 # mkdir -p /tmp/www
 while [ 1 ];
  do
  wl assoclist | awk '{print$2}' > /tmp/assocLIST
  # echo "<meta http-equiv="refresh" content="10"><b>Hostnames and IPs of WLAN clients</b> (last update: $(date))<p>"     > /tmp/www/wlan.html
  while read assocLINE
   do
     dumpleases | grep -i $assocLINE | awk '{print "Hostname: " $1, "MAC: " $2, "IP: " $3}'
   # echo "<br>";
        done < /tmp/assocLIST     # >> /tmp/www/wlan.html
  sleep 10;
done;

Output:

Hostname: tp MAC: 01:81:18:3d:49:5e IP: 192.168.2.101

You can change the order of "$1, $2, $3" or cut-out:

....awk '{print $1,$3}'

Output:

tp 192.168.2.101

if you want to show this in a browser remove the # and use: http://routerIP/user/wlan.html

To booting on startup see Startup Scripts

How can I protect this file? I want to allow showing this only if you are logged in the web interface! Please write it here, thanks

answer:name it wlan.asp