As Linux users, we sometimes need to change the MAC address of our network adapters. This process is also called 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, that stands for Media Access Control, is a six byte ID permanently embedded in the firmware of a network adapter. This address can be read by an operating system and network where the adapter is installed. All network nodes such as workstations and printers etc. are identified by these MAC addresses over the network. These addresses are identical, even for two similar device models of the same manufacturer. All MAC addresses need to follow the standards set by IEEE, the Institute of Electrical and Electronics Engineers.

Why change?

So why do we need to change a MAC address? There are mainly the following reasons to change it:

  • The most common reason to change a MAC address is to maintain privacy. If you are connected to a public network, the best way to keep your ID unexposed it to fake the MAC.
  • If a network administrator has blocked your MAC ID on a firewall or router, you can spoof it and be able to pass through.

How to View the MAC address?

In order to view 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 through Debian Application Launcher search as follows:

Open Debian terminal

This is the output you get:

Get MAC address

The above output from my system shows MAC addresses of three network devices installed on my system. The part after “link/ether” is where you will see the MAC address of a particular device but we have blurred it for privacy reasons.

There is another way to view MAC addresses, it is through the following “ip addr” command:

$ ip addr | grep ether

Other way to view MAC address

How to Change or Spoof your MAC Address?

In order to change the MAC address of a device, you first need to install a command line utility called the MacChanger.

Open the Terminal either through the Application Launcher search and then run the following command:

$ sudo apt-get install macchanger

Install macchanger

During the installation process, you will encounter the following configuration message:

Configuring macchanger

Select Yes through the arrow keys and then press Enter in order to configure macchanger to run automatically whenever a network device is brought up or down.

The following command will let you get the interface-name of a device that you will be using later to change its MAC address:

$ ip addr

Get network interface

The highlighted interface-name is the one we will be using in our following examples.

Setting up a Random MAC ID

The following command will assign a random, but viable, MAC ID to your network adapter:

Sytnax:

$ sudo macchanger -r <interface-name>

Example:

$ sudo macchanger -r enp37s0

Set Random MAC address

Setting up a specific MAC ID

The following command will assign a specific MAC id to your network adapter:

Sytnax:

$ macchanger --mac=XX:XX:XX:XX:XX:XX <interface-name>

Restoring the MAC address to the original

If you need to restore the MAC address of a device to its original state, you can use the following command:

Syntax:

$ sudo macchanger -p <interface-name>

Example:

$ sudo macchanger -p enp37s0

Restore original MAC address

Through the simple steps described in this article, you can view and change your Mac addresses and also restore them to the original ones whenever needed.

How to Change/Spoof a MAC Address in Debian 10
Avatar

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn