How to Permanently Change Your MAC Address on Linux

 

If you are looking for a way to permanently change the Media Access Control (MAC) address of your Linux device, this article will guide you through the process.

What Is a MAC Address?

A MAC address is a unique identifier used by network devices to communicate with each other. It consists of six hexadecimal numbers separated by a colon or a hyphen. The first three numbers usually represent the hardware manufacturer. Every network interface has a unique MAC address, which is used to identify connection endpoints.

Finding Your MAC Address

To find your current MAC address, use the ip command with the link object. This will list your network interfaces, whether they are in use or disconnected from the network.

Use macchanger to Change Your Linux MAC Address

The macchanger utility allows you to change the MAC address of a network interface with flexible options. You can set a specific MAC address or use a random one. You can also get a new MAC address that uses the same three OUI bytes as your hardware, so that the network interface manufacturer stays the same.

Here are the steps to install and use macchanger:

  1. Install macchanger on your system using the following command:
sudo apt install macchanger
  1. To change the MAC address of your Ethernet connection, use the following command:
sudo macchanger -r enp3s0

Here, -r generates a completely random MAC address, and enp3s0 is the name of the network interface you want to change.

How to Permanently Change a MAC Address

To permanently change your MAC address, you need to use a systemctl unit file. Follow these steps to create a unit file and set a new MAC address:

  1. Open a terminal and create a new systemctl unit file using the following command:
bash
sudo nano /etc/systemd/system/change_mac_address.service
  1. Paste the following lines into the file:
ruby
[Unit] Description=Change MAC Address [Service] ExecStart=/sbin/ip link set dev enp3s0 address XX:XX:XX:XX:XX:XX [Install] WantedBy=multi-user.target

Replace enp3s0 with the name of the network interface you want to change, and XX:XX:XX:XX:XX:XX with the new MAC address you want to set. 3. Save and close the file by pressing Ctrl + X, then Y, and Enter.

  1. Enable the service by running the following command:
bash
sudo systemctl enable change_mac_address.service
  1. Start the service by running the following command:
sql
sudo systemctl start change_mac_address.service

Your MAC address is now permanently changed. To check if the new MAC address is set, use the ip command with the link object.

Permanently Changing a MAC Address with GNOME

If you are using GNOME, you can also change your MAC address through the Settings menu. Here are the steps:

  1. Open the Settings menu and go to Wi-Fi [or Network] > Identity.
  2. Toggle the "Cloned MAC address" switch to "On".
  3. Enter a custom MAC address in the "MAC address" field.
  4. Click "Apply" to save the changes.

Be Careful!

Changing your MAC address can have unintended consequences, such as disrupting your network connection or violating your network's terms of service. Use these methods at your own risk and make sure you have a good reason for changing your MAC address.

Previous Post Next Post