I am running DD-WRT v.3.0 on my Linksys EA6500 router and I have the following script running in order to give me access to the WiFi MAC address that are currently connected to the router:

echo "#!/bin/ash" > /tmp/getmac.sh
echo 'echo { > /tmp/www/list.html' >>/tmp/getmac.sh
echo "for i in \$(arp | awk '{print toupper(\$4)}'); do echo \$i, >> /tmp/www/list.html; done" >>/tmp/getmac.sh
echo 'echo } >> /tmp/www/list.html' >>/tmp/getmac.sh
chmod +x /tmp/getmac.sh

I can visit and it will show me a list of WiFi MAC address that are currently connected to the router:


{ 01:81:18:3d:49:5e, 04:10:87:8c:47:9a, }

However, I would like to modify that to also include the IP ADDRESS and also the NAME OF THE DEVICE.

I found this on the DD-WRT website but when running the command and checking the directory, I do not see it anywhere.

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

I would like it to output like so:

    "data": [{
        "IP": "",
        "MAC": "01:81:18:3d:49:5e",
        "HOST": "DavidsAndroidPhone"
    }, {
        "IP": "",
        "MAC": "04:10:87:8c:47:9a",
        "HOST": "BobsIphone"

How can I modify my first script I posted to include the IP and NAME?


When I do the command arp in PuTTYtel I get the following info:

DD-WRT login: root

     ___  ___     _      _____  ______       ____  ___
    / _ \/ _ \___| | /| / / _ \/_  __/ _  __|_  / / _ \
   / // / // /___/ |/ |/ / , _/ / /   | |/ //_ <_/ // /
  /____/____/    |__/|__/_/|_| /_/    |___/____(_)___/

                       DD-WRT v3.0


BusyBox v1.24.1 (2016-03-07 05:09:22 CET) built-in shell (ash)

root@DD-WRT:~# arp
android-17af243062d3eb6b ( at 00:ae:fa:4a:3a:4c [ether]  on br0

So currently the script I am running (getmac.sh) looks at this and gets only this:

{ 00:ae:fa:4a:3a:4c, }

So given that, how can I modify the script to get more of the information I am looking for in the proper JSON layout?


Ok I have this code here:

arp | awk 'BEGIN { print "{" } { print "MAC:" $4 ", IP:" $2 ", HOST:" $1} END { print "}" }'

Which outputs the following:

MAC:00:ae:fa:4a:3a:4c, IP:(, HOST:android-17af243062d3eb6b

Now given that above, how can I remove the ( and the ) from the IP and format it in proper JSON form? I've tried awk -F'(' but that doesn't seem to work.

  • What are the contents of /tmp/assocLIST? Please edit your post to include that intermediate file used by the script. – Anthon Mar 20 '16 at 5:27
  • @Anthon Oddly enough that does not exist either. Just like /tmp/getmac.sh wasent there until I created it. So I am guessing it creates that .sh script when I execute the script. But like i said, it doesnt show up on the file system like getmac.sh does. – StealthRT Mar 20 '16 at 5:34
  • The script should create it. Do you have the wl command installed? What does wl assoclist give when run on its own? If that doesn't produce output, it is no wonder the rest of the script doesn't either. – Anthon Mar 20 '16 at 5:38
  • @Anthon Nope, not producing any output when doing that command in PuTTytel. How can I fix that? – StealthRT Mar 20 '16 at 5:43
  • Assuming that you are not running in client mode this should work, but I cannot test it as I have not been running dd-wrt for a long time. – Anthon Mar 20 '16 at 5:48

Ok, this will need some work, but to start check what are the adapters with


Then run:

wl -i ethX assoclist 

until you find the one that ddwrt is using for your wifi. You still have to mess a bit to get your exact output structure but the original script (plus -i adapter) should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.