get the MAC address on Raspberry Pi

How to Find the MAC Address on Raspberry Pi (3 easy ways)

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:

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now
  • 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).

Join Our Community!

Connect, learn, and grow with other Raspberry Pi enthusiasts. Support RaspberryTips and enjoy an ad-free reading experience. Get exclusive monthly video tutorials and many other benefits.

Learn more

To do this, I like to use Advanced IP Scanner on Windows:

  • Start by downloading it here:
  • 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:
  • And use it in your Python script like this:
    from getmac import get_mac_address

    eth_mac = get_mac_address()

  • 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:

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now
import re,uuid

mac=':'.join(re.findall('..', '%012x' % uuid.getnode()))

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:
  • Paste the following lines in it:
    if [ -e /sys/class/net/eth0 ]; then
    MAC=$(cat /sys/class/net/eth0/address)
    MAC=$(cat /sys/class/net/wlan0/address)

    echo $MAC
  • Add the execution right:
    chmod +x
  • Run the script with:

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?

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now


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:
This added my Raspberry Pi Zero 2 to the ARP cache.

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

Reminder: Remember that all the members of my community get access to this website without ads, exclusive courses and much more. You can become part of this community for as little as $5 per month & get all the benefits immediately.


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 :).

Whenever you’re ready, here are other ways I can help you:

The RaspberryTips Community: If you want to hang out with me and other Raspberry Pi fans, you can join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.

Master your Raspberry Pi in 30 days: 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.

The Raspberry Pi Bootcamp: Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.

Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.

You can also find all my recommendations for tools and hardware on this page.

Similar Posts


  1. Hi, Patrick! I must say right away that my knowledge of networks is extremely small.
    I have a problem, my raspberry has a static IP address in dhcpcd.conf and it is not specified correctly (most likely, this is an error in the gateway or in the value of the final address).
    There is no physical access to raspberries. How can I find it on the network with incorrect settings? Can an advanced IP scanner help you find it?

    1. Hello,
      In theory, if it’s just a gateway problem, you can access it from the same network (set your computer on the same network for example)

Comments are closed.