Just like each house in the street has its own postal address, the mac address is a unique identifier which differentiates the device from other devices connected on the same internet. The mac address is a 48 bit unique identification of a device which is the only way to track a specific device on the internet.
Every device connected to the internet has two addresses: IP address and Mac address, and if you want to communicate with two devices, you must have both. You are familiar with getting the mac address on Windows, but if you are new to using the Raspberry Pi device, you will definitely require help in obtaining your Raspberry Pi mac address. If you are having trouble determining the mac address of your Raspberry Pi device, you can get guidance by following the methods outlined in this article.
Getting mac address of Raspberry Pi
Here, we will provide you with some methods that you can easily do on your Raspberry Pi terminal and get to know your Raspberry Pi mac address within a few seconds.
1 : Using IP command to get mac address of Raspberry Pi
One of the easiest methods to get your Raspberry Pi mac address is the ip command which runs on your Raspberry Pi’s terminal and shows you the list of mac addresses of the devices which are connected with your network.
Before you can get the mac address of Raspberry Pi, you will need to find a list of devices attached to your network. To do so, enter the below given command in the terminal and you will see the results as shown below.
Now in the above window, the address after the text “link/ether” is your mac address of your Raspberry Pi device and is highlighted in the image below.
2 : ifconfig command to get mac address of Raspberry Pi
There is another useful command called “ifconfig” which provides you with all the interfaces which are connected to your network and you can find the mac address of Raspberry Pi on it as well. In order to run it, you need to add the below mentioned command in the terminal and as soon as you press enter, you will find your Raspberry Pi mac address as shown in the image below.
If you want to get the mac address from a specific interface, you can do that after having the list of all interfaces on your terminal. Suppose, you need to find the address of eth0 interface then you have to enter the command as shown below.
The address “dc:a6:32:f3:73:44” which comes after the ether is your Raspberry Pi mac address.
3 : Using cat command to get mac address of Raspberry Pi
There is another method which you can use if you are interested in getting your Raspberry Pi mac address on the terminal. The cat command will receive the information from the files which are located in the system directory. So, in order to find the mac address for the desired interface, you need to provide the location of the director “/sys/class/net” followed by network interface “eth0” and end it with “/address” to get the mac address on the terminal. The command will look like below and you will see the desired mac address of Raspberry Pi on the terminal.
4: Using the Python Code to get the mac address
Using a built-in Python code which can help you to get the mac address of Raspberry Pi. You can get the code through the command-line in the terminal.
Next, to run the Python script, you need to enter the command which is similar to the one shown below.
There, you will see your Raspberry Pi mac address in the Ethernet Mac Address as highlighted in the below image.
In this article, you will be able to find different methods starting with the most basic one and ending with getting the mac address through a python code. You certainly need a command if you want to connect more devices with your Raspberry Pi because in that case Mac address is the only way which will help you to get your work done.