Get MAC address from file system

On Debian based Linux distributions you can get the MAC address of the respective network adapter from the filesystem like shown below:

As you can see, all adapters have their own folder under  /sys/class/net/ that contains  a address file with the corresponding MAC address.

If the system is not booted (offline edit). You can have a look into the file /etc/udev/rules.d/70-persistent-net.rules to get the MAC addresses of the installed network adapters.

That is very useful especially if you had the operating system on a SD card like on Raspian or Bananian and if you want to register the MAC address for a new network you want to sign in (MAC-filter). You can plug the card into you computer and read out the MAC address to add it to the MAC whitelist of your router. You can also configure your network connection over the filesstem as described here. So you can setup all network configurations directly on the card and plug it into the Pi again to get access to the current network.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.