Get MAC address of connected device

Hi I have ssh connection to my OpenWrt router from mobile phone I want to get mobile phone's mac address from executing command in OpenWrt shell is there any way to do it?

There are several ways

iwinfo wlan0 assoclist

or

ubus call hostapd.wlan0 get_clients

or

iw ...
1 Like

instead of getting list can I get exactly one ( which is mobile phone I'am running )

Can u setup luci?
And then just go to the Associated Clients.
Often there you can see the hostname and IP + MAC.

1 Like
ip neigh show "${SSH_CONNECTION%% *}" | cut -d " " -f 5
4 Likes

Get the IP address from the environment, if dropbear supports it. Use the ARP table to get the associated MAC, wireless or wired. (See post above)

4 Likes

Exactly What I wanted , THANK YOU..

1 Like

Hi can I get device's MAC address as this?

Do you need the MAC address of the router?
If so, then LAN or WAN interface?

WLAN interface

ip link show wlan0 | awk -e '/^\s*link\//{print $2}'
ip link show br-lan | awk -e '/^\s*link\//{print $2}'

perfect , Thanks again

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.