Home Linux Commandline Tools How to Change Network MAC Address in Linux

How to Change Network MAC Address in Linux

Every network interface on your Linux operating system distribution is associated with a unique number called MAC (Media Access Control). The wireless and Ethernet network modules are examples of commonly used network interfaces on a Linux operating system. MAC serves a unique role in identifying these network interfaces through system protocols and programs.

For example, through DHCP (Dynamic Host Control Protocol), a network interface is assigned an IP address by a network router automatically. In this case, the MAC address acts as a reference manual for networking devices like the router so that these devices know the identity of the other network devices they are communicating with or, in this case, assigning IP addresses.

Why Change Your MAC Address?

The MAC address is different from an IP address such that it is hardware-oriented whereas an IP address is software-oriented. Therefore, an IP address can be permanently changed whereas changing a MAC address is only temporary. If you restart your machine it will default to its original manufacturer’s value.

Three prime reasons as to why you might need to temporarily change your MAC address stand out:

  • You do not trust the public network you are using and therefore don’t want your MAC address to be exposed as it can be used to permanently identify your machine whenever you are on a network.
  • A firewall or router has been used to block your original MAC address to deny you access to a specific network.
  • Airport WiFi and other public networks operate on the “Limited Time Access” rule when it comes to gifting free internet to their clients. Changing the MAC address can bypass this limitation.

Install MAC Changer in Linux

This Linux operating system software package will help us meet the objective of this article guide. We need to make sure that macchanger is installed on your Linux distribution.

Reference the following installation commands in regards to your Linux distribution:

$ sudo apt-get install macchanger     [On Debian, Ubuntu and Mint]
$ sudo yum install macchanger         [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a sys-apps/macchanger  [On Gentoo Linux]
$ sudo pacman -S macchanger           [On Arch Linux]
$ sudo zypper install macchanger      [On OpenSUSE]    

You are bound to run into the following prompt during the installation process.

Configure Mac Changer in Linux
Configure Mac Changer in Linux

If you choose yes, all your online presence will be associated with a new MAC address even after a successful system reboot. If you only need to change your MAC address occasionally, you should proceed with an option no.

Wait for the macchanger installation process to complete.

Changing Linux MAC Address

The use of the macchanger command should be associated with a network interface. The first step is to identify the available interfaces on your network which most of the time include loopback, wireless, and wired.

We will use the following IP command:

$ ip a
Check Linux MAC Address
Check Linux MAC Address

From the screen capture above, the wireless interface wlp2s0b1 is associated with the MAC address ec:55:f9:55:8a:ab. To temporarily change this MAC address, you will need to be a root user or have sudo privileges on your Linux machine.

To change the above MAC address, we will use the macchanger command together with the -r option and point to the network interface whose MAC address we need to temporarily change.

$ sudo macchanger -r wlp2s0b1
Change MAC Address
Change MAC Address

To avoid the above [ERROR] that says:

[ERROR] Could not change MAC: interface up or insufficient permissions: Device or resource busy

1. Stop your network manager.

$ sudo service network-manager stop

2. Take down the targeted network interface.

$ ifconfig wlp2s0b1 down

3. Now change your MAC address.

$ sudo macchanger -r wlp2s0b1
Change MAC Address in Linux
Change MAC Address in Linux

4. Restart your network manager and the associated network interface.

$ sudo service network-manager start 
$ sudo ifconfig wlp2s0b1 up

Let us now recheck the existence of the new MAC address:

$ ip a
Check Linux MAC Address
Check Linux MAC Address

The temporary new MAC address has been configured and implemented as expected.

If you want your network identity to be associated with a specific MAC address, you can reference the following macchanger command syntax:

$ sudo macchanger -m [your_custom_MAC_address] [Targeted_network_interface]

An example implementation would be:

$ sudo macchanger -m f7:ed:56:0e:aa:b2 enp0s3

Changing the MAC address on a Linux operating system environment gives you the flexibility of bypassing the limitation of various network administration rules and also the anonymity advantage. You get to play by your own network rules.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

3 thoughts on “How to Change Network MAC Address in Linux”

  1. Thank you for the article. One of the problems is that often the connection to the internet is lost after changing the MAC address. Can this problem be averted by changing both the IP address and MAC address at the same time?

    Reply

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.