In the unmodified linksys WRT54G, you can go to some screen and figure out the MAC Addresses of the computers connected to you. Does that exist in OpenWRT? I know ifconfig will get me MY mac address, is there some command like that to give you the Mac Addresses of the connected computers?
Topic: MAC Address of connected clients
The content of this topic has been archived on 18 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.
I am dumb =Þ
Nevermind, I figured it out, script coming soon for reference to others.
I need your script! Have you one ?
wl assoclist
yeah, I knew about the assoclist, but I needed the mac address of the gateway for the wan port. I have to lock my clients onto the first thing they plug this into. Assoclist would probably work for most people though.
Dev, gimme today to organize my thoughts and I will post what I do go to the gateway mac. Most people probably will not need to lock their clients into one gateway though so this may not be what you need.
I need data about Signal and Link Quality and noise, a dont want to log my clients.
i only want to improve my links and transferspeed.
wl assoclist - dont work for me
Well here, eventually I will probably put this up on some mini-howto somewhere but here is a summary for you now.
first, let me just say that I use scripts to do things like find the IPs and gateways. So I am going to post these scripts for reference. It is easier for me to remember /usr/bin/whatismygw than all that grepping(sp?) and such
whatismygw looks like this
#!/bin/sh
netstat -rn | grep UG|tail -1 | awk '{print $2}'whatismygwmac looks like this:
#!/bin/sh
arping -fq -I vlan1 `whatismygwpptp`
cat /proc/net/arp | grep `whatismygwpptp` | awk '{print $4}'Ok, little explanation,
On the GW one. I need a way to easily find my gateway. So I use the netstat -rn command to list my routes and I grab the one where the flag is UG (U = useable or active; G = gateway). I actually use this little one line script to find my gateway in a lot of my other scripts, which is why I wrote something to easily reference it.
As for the whatismygwmac script. I use arping to get the MAC address in the arp tables. For those who don't know a whole lot about arping (I don't either), let me break down what I am doing there for you. arping -fq -I vlan1 `whatismygw`. -f means stop after the first response (I only need to ping once to get the mac address). -q means stfu, so no extra info is put in variables if I set them like so
mymacgw=`whatismygwmac`otherwise, the response from the script would be:
arping: connect
{my mac address}
which has one line too much information. I just assume arping connected so I don't care about the response. Continuing on, -I tells you what interface to use. In my case, I am trying to get the MAC address of my router's gateway, so I use vlan1 (my wan port). If you are trying to do this to something on the inside, you would have to modify it accordingly. A note about the -I tag, you don't have to use it. If for some reason, you don't know what interface you are looking for you can set it like
arping -fq -c 1 `whatismygw`
The "-c 1" means that it only would try on each interface once before it moved on (count = 1). I really do not recommend this way of doing things as you then have to put a pause in your script to allow the arping to make it through all the interfaces. The script may look something like this:
#!/bin/sh
arping -fq -c 1 `whatismygw`
sleep {# of seconds needed}
cat /proc/net/arp | grep `whatismygw` | awk '{print $4}'You will probably have to pause at least 5 seconds to let arping scan all interfaces.
Finally you would replace `whatismygw` with whatever IP you are trying to find the MAC address for.
PLEASE NOTE
I am not very good at any for of scripting. So there is a good chance that there is a better way to do this. Also, any script I posted after "Ok, little explanation," is just theorectical. I didn't test it before I posted it so there is a chance it won't work if you just copy paste. You may have to tweak a little bit to fix my mistakes.
I do know that the first two snippets of code I posted are good because I pasted them right out of my shell.
Lemme know if you have any questions. May be better off to PM or email me, because I check stuff sporatically.
Sorry about any spelling errors.
(Last edited by t0ksik on 23 Nov 2005, 17:23)
The discussion might have continued from here.
