Determine devices attached to router
Moderator: Martin
Determine devices attached to router
I would like to program old cell phone to put our HVAC system in vacation mode when our cell phones are not connected to our router. I can get a gui up from our router web page, but how can I get a list of Mac addresses of attached devices to automatic?
Re: Determine devices attached to router
If you have linux-based router with ssh access, you can use action Execute SSH Command, something (roughly) like this:
output will be like this (MAC ms-of-inactive-time):
xx:yy:zz:c9:d9:73 10
xx:yy:zz:a7:63:05 4120
xx:yy:zz:c0:8b:79 2380
xx:yy:zz:3b:05:60 60
xx:yy:zz:75:37:a3 7180
you can parse this output and do something based on MAC presence and (maybe) inactivity time.
P.S. you can get your actual device name (Interface) for iw dev $DEVICE … from:
Code: Select all
iw dev ath0 station dump | awk '{if($1=="Station") printf "%s ",$2; if($1~"inactive") printf "%s\n",$3}'
xx:yy:zz:c9:d9:73 10
xx:yy:zz:a7:63:05 4120
xx:yy:zz:c0:8b:79 2380
xx:yy:zz:3b:05:60 60
xx:yy:zz:75:37:a3 7180
you can parse this output and do something based on MAC presence and (maybe) inactivity time.
P.S. you can get your actual device name (Interface) for iw dev $DEVICE … from:
Code: Select all
# iw dev
phy#1
Interface ath1
ifindex 8
wdev 0x100000002
addr xx:yy:zz:e7:b7:e9
ssid MYSSID
type AP
channel 149 (5745 MHz), width: 20 MHz, center1: 5745 MHz
phy#0
Interface ath0
ifindex 7
wdev 0x2
addr xx:yy:zz:e7:b7:e8
ssid MYSSID2
type AP
channel 6 (2437 MHz), width: 20 MHz, center1: 2437 MHz
Re: Determine devices attached to router
If you can get the GUI / web based UI from the router, and your router doesn't support any SSH or telnet; you can use HTTP request to retrieve the GUI. It is quite difficult, as it varies depends on the router. You also have to mimic the login session using the proper username/password. Then parse the response using regex to list out all the mac.
I use the similar one to retrieve all the mac address and hostname from it. So I know whose devices are connected at the moment (I have given each devices names based on the mac address).
I use the similar one to retrieve all the mac address and hostname from it. So I know whose devices are connected at the moment (I have given each devices names based on the mac address).
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.