1. Using the Terminal:
The easiest way to find the MAC address on a Raspberry Pi is to open a terminal window and type the command “ifconfig”. This will display all of the network interfaces on the Raspberry Pi, including the MAC address.
2. Using the GUI:
If you are using the Raspberry Pi with a graphical user interface, you can find the MAC address by opening the network settings. The MAC address will be listed under the “Hardware Address” field.
3. Using the Raspberry Pi Configuration Tool:
The Raspberry Pi Configuration Tool (raspi-config) is a command line tool that can be used to configure various settings on the Raspberry Pi. To find the MAC address, open the tool and select “Network Options”. The MAC address will be listed under the “Ethernet” section.
On some networks, you can configure a MAC address whitelist to only allow authorized devices. You probably know how to do this on other systems (i.e. Windows), but you might need help finding it on Raspberry Pi. I will share everything you need to know about finding the MAC address on your Raspberry Pi.
The easiest way to find the MAC address on a Raspberry Pi is to use the “ifconfig” command. You’ll find the MAC address after the keyword “ether” in the section corresponding to your network interface. It’s represented as a 12-digit hexadecimal number (AA:BB:CC:DD:EE:FF).
In this tutorial, I’ll show you how to find your MAC address with ifconfig. I will also share additional ways for you to find it in different situations.
If you’re looking to quickly progress on Raspberry Pi, you can check out my e-book here. It’s a 30-day challenge where you learn one new thing every day until you become a Raspberry Pi expert. The first third of the book teaches you the basics, but the following chapters include projects you can try on your own.
What is a MAC Address?
If you are still not sure what we are talking about here, I recommend that you take 5 minutes to watch this video. Everything will be clearer, and you will be able to follow my instructions more easily after that.
Find the MAC Address on Raspberry Pi OS
So, the first way to find your MAC address on Raspberry Pi OS is to use ifconfig
.
This command is available on any Raspberry Pi OS version (Lite or Desktop).
On Raspberry Pi OS Lite, you can use it once logged on.
On Raspberry Pi OS Desktop, you need to open a terminal before you can use it.
Here is how to do this on Raspberry Pi OS Desktop:
- Open the terminal (shortcut in the top bar):
- Type the
ifconfig
command and press enter. - The result looks like the following:
- You can see one paragraph per network card on your system.
eth0 corresponds to the wired card, and wlan0 is the Wi-Fi card.
In each paragraph, you can see the IPv4 and IPv6 configuration, the MAC address and a few statistics about the network card. - The MAC address is visible after the “ether” keyword, here:
- So, in this case, the MAC address is b8:27:eb:4f:15:95.
That’s it! You can now do the same thing on your Raspberry Pi, and use the MAC address in your router configuration.
Note: The “ifconfig” command is progressively removed on new distributions. If this command is not available on your system, you can use “ip a” instead. You’ll get a similar result, including the IP and MAC addresses.
Are you a bit lost in the Linux command line? Check this article first for the most important commands to remember, and a free downloadable cheat sheet so you can have the commands at your fingertips.
Get the MAC Address in a network scan
If your goal isn’t to authorize a device to access your network, but to assign it a static IP address in the DHCP server, you can also scan the network to find equipment connected to the network (including any Raspberry Pi).
To do this, I like to use Advanced IP Scanner on Windows:
- Start by downloading it here: https://www.advanced-ip-scanner.com/.
- Install it like any other application and then start it.
- Enter the network range to scan.
I think the software will detect it automatically. - And press the “Scan” button.
- After a few seconds, you’ll get the full list of your network devices, like this:
- And as you can see on the highlighted line, you can also get your Raspberry Pi MAC address this way!
Get the MAC Address in a script
The last scenario I can think of is if you need to get the MAC address in a script to use on many Linux systems, including some Raspberry Pi. I will show you here two ways to do this: in Python and in a Shell script.
Python script
Python is a popular language on Raspberry Pi and is also available on any operating system. So, it’s a good idea to use it for your projects. I have an introduction tutorial to Python on this website, it’s probably a good idea to start there if you are new to this.
If you need to find the MAC address of a system in Python, there are several ways to do this.
I prefer to keep it simple by installing get-mac and using it directly in your code.
Here is how to do this:
- If not yet installed, you need to install pip on your system:
sudo apt install python-pip
- Then install get-mac with the pip command:
sudo pip install get-mac
The project page is here if you need more information.
And you can also check this other article to learn more about installing new packages for Python on Raspberry Pi. - Once installed, you can create a new Python file:
nano mac.py
- And use it in your Python script like this:
from getmac import get_mac_address
eth_mac = get_mac_address()
print(eth_mac)
- There are many options you can use. For example, to get the MAC address from a remote device or to specify if you want the eth0 or wlan0 address.
All the information is on the project website.
If you prefer not to install anything on your system, you can use the uuid library.
The cleanest way, that I found, to get it is like this:
import re,uuidmac=":".join(re.findall('..', '%012x' % uuid.getnode()))
print(mac)
uuid.getnode() returns the identifier, and you need to use join and findall to format it the correct way.
If you are new to Python programming, I highly recommend starting with this article, which will explain the basics. It’s not complicated, but you have to learn in the correct order before trying this.
Shell script
The last method I want to show you is in a shell script, which is where we generally use system commands.
As far as I know, there isn’t a command to directly get the MAC address, but you can read the /sys/class/net/<INTERFACE>/address file to find the MAC address currently used.
You can do something like the following, for example:
- Create a new script, for example:
nano get-mac.sh
- Paste the following lines in it:
#!/bin/sh
if [ -e /sys/class/net/eth0 ]; then
MAC=$(cat /sys/class/net/eth0/address)
else
MAC=$(cat /sys/class/net/wlan0/address)
fiecho $MAC
- Add the execution right:
chmod +x get-mac.sh
- Run the script with:
./get-mac.sh
This script tries to read the file corresponding to eth0.
If it doesn’t exist, it reads the wlan0 file.
Related article: Should You Learn Linux or Python first?
FAQ
What are the possible ranges for Raspberry Pi MAC addresses?
According to the MAC vendors list, all Raspberry Pi MAC addresses start with 28:CD:C1, B8:27:EB, DC:26:32 or E4:5F:01.
If you find a device starting with one of these during a network scan, this is probably the Raspberry Pi MAC address you are looking for.
As a reminder, each network card manufacturer is assigned a specific range. A MAC address needs to be unique on a network, so the goal is to avoid conflicts by giving a unique range to each brand. The Raspberry Pi Foundation follows the same rule as any other manufacturer.
How to get the MAC address from the IP address
If you know the IP address, you can either do a network scan to find the MAC address or simply check the ARP cache with the command:arp -a
The easiest way is probably to use the network scanner I introduced previously. But if you are comfortable using a command line, you can try the arp command from any computer on the same network (it works from any system).
For example, from my Raspberry Pi 4, I get something like:
I now know my Raspberry Pi Zero 2 MAC address, without having to access it via SSH.
The ARP cache only shows devices that your computer interacted with. So, if the list is incomplete, you can add it by doing a ping of the IP address:ping 192.168.222.3
This added my Raspberry Pi Zero 2 to the ARP cache.
Want to chat with other Raspberry Pi enthusiasts? Join the community, share your current projects and ask for help directly in the forums.
Conclusion
That’s it, you now know how to get the current address MAC on a Raspberry Pi. You learned the basic way (ifconfig), but also alternative methods to get it depending on your needs.
If you have any other case where you need to get it, feel free to leave a comment in the community, so I can try to help you.
As usual, thanks for sharing this post on your favorite social network if you find it useful :).
Additional Resources
Not sure where to start?
Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Watch the Raspberry Pi Bootcamp course now.
Master your Raspberry Pi in 30 days
Don’t want the basic stuff only? If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.
Download the e-book.
VIP Community
If you just want to hang out with me and other Raspberry Pi fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
More details here.
Need help building something with Python?
Create, understand, and improve any Python script for your Raspberry Pi.
Learn the essentials step-by-step without losing time understanding useless concepts.
Get the e-book now.
You can also find all my recommendations for tools and hardware on this page.
How to Find the MAC Address on Raspberry Pi (3 Easy Ways)
The MAC address (Media Access Control address) is a unique identifier assigned to the network interface of a device. It is used to identify the device on a network. If you are using a Raspberry Pi, you may need to find the MAC address of your device. Here are three easy ways to find the MAC address of your Raspberry Pi.
Method 1: Using the ifconfig Command
The ifconfig command is a simple tool for viewing and configuring network interfaces. To find the MAC address of your Raspberry Pi, open a terminal window and type the following command:
ifconfig
This will display a list of network interfaces and their associated MAC addresses. The MAC address will be listed as the “HWaddr” for the interface.
Method 2: Using the ip Command
The ip command is a powerful tool for viewing and configuring network interfaces. To find the MAC address of your Raspberry Pi, open a terminal window and type the following command:
ip link show
This will display a list of network interfaces and their associated MAC addresses. The MAC address will be listed as the “link/ether” for the interface.
Method 3: Using the arp Command
The arp command is a simple tool for viewing the Address Resolution Protocol (ARP) cache. To find the MAC address of your Raspberry Pi, open a terminal window and type the following command:
arp -a
This will display a list of IP addresses and their associated MAC addresses. The MAC address will be listed as the “ether” for the IP address.
These are three easy ways to find the MAC address of your Raspberry Pi. Once you have the MAC address, you can use it to configure your network or troubleshoot network issues.