As Linux users, we sometimes need to change the MAC address of our network adapters. This process is also known as spoofing or faking a MAC address. This article explains how to change a MAC address on a Debian 10 Buster system.
What is a MAC address?
MAC, which stands for Media Access Control, is a six-byte ID that is firmly embedded in the firmware of a network adapter. This address can be read by an operating system and network on which the adapter is installed. All network nodes such as workstations and printers etc. are identified via these MAC addresses over the network. These addresses are also identical for two similar device models from the same manufacturer. All MAC addresses must conform to the standards of IEEE, the Institute of Electrical and Electronics Engineers.
So why do we need to change a MAC address? The main reasons for changing it are as follows:
- The most common reason to change a MAC address is to protect privacy. When connected to a public network, it is best to keep your ID undetected in order to forge MAC.
- If a network administrator has blocked your MAC ID on a firewall or router, you can forge it and pass it through.
How to view the MAC address
To see the MAC addresses of all your network devices you can use the following command on your Debian terminal:
$ ip link show
Tip: You can open the terminal from the Debian Application Launcher search as follows:
This is the output you will get:
The output of my system above shows the MAC addresses of three network devices installed on my system. In the part after “Link / Ether” you can see the MAC address of a specific device, but we have blurred it for privacy reasons.
There is another way to display MAC addresses by using the following “ip addr” command:
$ ip addr | grep ether
How to change or forge your MAC address
To change a device’s MAC address, you first need to install a command line utility called MacChanger.
Either open the Terminal via Application Launcher search, then run the following command:
$ sudo apt-get install macchanger
The following configuration message is displayed during the installation process:
Use the arrow keys to select Yes, and then press Enter to configure the macchanger to run automatically whenever a network device boots up or shuts down.
The following command can be used to get the interface name of a device that you will later use to change its MAC address:
$ ip addr
The highlighted interface name is the one we’ll use in our examples below.
Set up a random MAC ID
The following command will assign a random but usable MAC ID to your network adapter:
$ sudo macchanger -r
$ sudo macchanger -r enp37s0
Set up a specific MAC ID
The following command assigns a specific MAC ID to your network adapter:
$ macchanger --mac=XX:XX:XX:XX:XX:XX <interface-name>
Restoring the MAC address to the original
If you need to reset a device’s MAC address to its original state, you can use the following command:
$ sudo macchanger -p
$ sudo macchanger -p enp37s0
By following the simple steps outlined in this article, you can view and change your Mac addresses and also restore them to the original addresses if necessary.