I have an Ubuntu server in a local network that has a number of other devices on the network, both LAN and wireless. I would like to run a Bash script to find out the MAC address (only one per machine) of the interface that is in use on all the machines in the local network. This means depending on what someone's laptop was using (LAN or wireless or other) that it would return only address of the active interface.
I'm not sure which command to use (maybe arp?). ifconfig
works only for my local machine, but I would like to do something like this regular expression from Stack Overflow question Best way to extract MAC address from ifconfig's output?.
How can I do this?