close

How to get the MAC Address in Kali Linux

Last Updated : 11 Mar, 2026

A MAC (Media Access Control) address is a unique hardware identifier assigned by the Network Interface Controller (NIC). It operates at the Data Link Layer (Layer 2) of the OSI model and is used to uniquely identify devices within a local network.

Note: On modern Linux systems (including Kali Linux), network interfaces may not always be named eth0. You may see names like enp0s3, wlan0, or similar.

How to get the MAC Address

Below are 10 reliable methods to retrieve the MAC address on Linux systems.

Method 1: Using ifconfig command

ifconfig | grep ether

Using ifconfig command
Using ifconfig command

In the above screenshot, you can see that the address that follows the "ether" is our actual desired MAC address.

Method 2: Reading the Interface Address File

Step 1:

  • we will print the MAC address by accessing the current interface file which is stored in the directory of /sys/class/net/eth0/address.
  • We can use any of the editors, or command line utility (cat) to view the contents of this file and get the MAC address.

cat /sys/class/net/eth0/address

Printing current interface address
Printing current interface address

Step 2:

  • As the above command gives only the current interface address, if we need to get the address of all the interfaces then we can use the below command in the terminal.

cat /sys/class/net/*/address

Printing all interface address
Printing all interface address

Method 3: Using grep with Regex

  • In this method, we will be using the grep command along with the custom regex expression which will work for us to get the MAC address of our system. So run the below command in the terminal to get the MAC address.

ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'

Using grep with regex expression
Using grep with regex expression

Method 4: Using the ip command

Step 1:

  • we will use the inbuilt IP link command to see the MAC address of our eth0 interface.
  • We can also see the address of any interface, just by giving the interface name as an input.

Run the below command to get the MAC address.

ip link show eth0

Using IP command
Using IP command

Step 2:

  • Here, we will display the MAC address using the more verbose format. We can use the awk command to display only the address rather than other stuff.

ip link show eth0 | awk '/ether/ {print $2}'

Only MAC address output
Only MAC address output

Method 5: Using ip with the grep command

  • In this method, we will use the combination of the ip and grep commands to get the MAC address along with more configuration information about the interface. So run the below command to get the address along with the information.

ip addr | grep -C1 "link/ether"

Using IP with grep command
Using IP with grep command

Method 6: Using ifconfig with the grep command

  • In this command, we will use the ifconfig along with the grep command to get the MAC address of our Kali Linux system. So run the below command in the terminal to get the MAC address.

ifconfig eth0 | grep -Eo ..\(\:..\){5}

Using ifconfig with grep command
Using ifconfig with grep command

Method 7: Using the LANG variable

  • In this method, we will use the LANFG variable to display the MAC address. So run the below command to get the MAC address by displaying the variable.

LANG=C ip link show | awk ‘/link\/ether/ {print $2}’

Using Variable
Using Variable

Method 8: Using ethtool utility

  • In this method, we get the MAC address of our system by using the tool name "ethtool". This tool is already present in our Kali Linux system. We just need to run the below command and get the MAC address.

ethtool -P eth0 | awk ‘{print $NF}’

Using ethtool utlity
Using ethtool utlity

Method 9: Using Python Script

  • Step 1: In this method, we will be writing our own Python script and getting the MAC address. So using any of the editors, write the below Python script. Save the file with the (.py) extension.
Python
import os

sys_net = '/sys/class/net'
for dev in os.listdir(sys_net):
    with open(os.path.join(os.path.join(sys_net, dev), 'address')) as f:
        print(dev, f.read(), end='')

Step 2:

  • Now, by using the Python command run the script and get the MAC address on your terminal printed in just one click.

python3 mac.py

Using Python script
Using Python script

Method 10: Using the dmesg command

  • In this method, we will be using the open-source utility named dmesg to get the MAC address of our system. So run the below command in the terminal to get the MAC address.

dmesg | grep eth

Using dmesg command
Using dmesg command
Comment

Explore