Unleash Your Linux Power: Permanently Alter Your MAC Address

Unleash Your Linux Power: Permanently Alter Your MAC Address

Learn how to permanently change your MAC address on Linux with ease MAC addresses are unique identifiers for network connections, but with the right tools, you can change them Follow our step-by-step guide and ensure your privacy and security while browsing the web

A MAC address serves as a unique identifier for devices on a network and is crucial in identifying connection endpoints. Each network interface has a specific MAC address set by the manufacturer, and it's possible to permanently change it on Linux using the macchanger utility or through GNOME settings. Network equipment typically has at least one network interface, with some devices having multiple network cards installed. A MAC address comprises six hexadecimal numbers separated by a colon or hyphen and must be unique to avoid spoofing.

The first three numbers of a MAC address indicate the hardware manufacturer's organizationally unique identifier (OUI). You can use the Wireshark Manufacturer Lookup page to decode the OUI, but keep in mind that it may not necessarily be the manufacturer of your computer. Manufacturers often purchase components from different sources and assemble them into the final product. As MAC addresses are built-in, they cannot be changed, but you can configure your Linux system to pretend to have a different MAC address. To check your current MAC address, use the ip command with the link object, which will list your network interfaces, whether they are in use or disconnected from the network. This computer has an active Wi-Fi connection on wlan0 and an inactive wired Ethernet connection on enp3s0, with the default loopback connection, lo, configured.

The macchanger utility is a versatile tool that allows you to modify the MAC address of your network interface. With macchanger, you have the option to either set a specific MAC address or generate a random one. Additionally, you can obtain a new MAC address that retains the same three OUI bytes as your hardware to maintain the manufacturer of your network interface.

To install macchanger on Ubuntu, simply use the command:

sudo apt install macchanger

On Fedora, the installation process requires the following command:

Unleash Your Linux Power: Permanently Alter Your MAC Address


To install macchanger on your system, simply use the command "sudo dnf install macchanger" for Fedora-based systems or "sudo pacman -S macchanger" for Manjaro Linux. If your distribution's version of macchanger offers the option to create a new MAC address every time a network connection is established, you may see a prompt asking for your preference.

To select an option, use the arrow keys to highlight and press "Enter". However, we recommend selecting "No" to have more control over MAC addresses and avoid changing them on every network interface. If you only want to change the MAC address on a specific interface, such as Wi-Fi, this method allows for that customization.

To change the MAC address, the network interface must not be in use. For example, the Ethernet connection can be changed because it is inactive. Use the "-r" option for a completely random MAC address and specify the name of the network interface to set the new MAC address.

Please see

- Using macchanger to Temporarily Change a MAC Address

for more information and

Unleash Your Linux Power: Permanently Alter Your MAC Address

for reference.

The underlying hardware MAC address, also known as the permanent MAC address, was previously being used as the MAC address. The updated MAC address can be seen at the bottom. To change the Wi-Fi card's MAC address, the Wi-Fi adapter must first be brought down, followed by changing the MAC address, and then enabling the Wi-Fi adapter using the following commands:

sudo networkctl down wlan0

sudo macchanger -r wlan0

sudo networkctl up wlan0

Unleash Your Linux Power: Permanently Alter Your MAC Address


If you prefer a specific MAC address, you can use the -m option and input the desired MAC address in lowercase hexadecimal format separated by colons ":".

To ensure our laptop has a new MAC address for its Ethernet and Wi-Fi interfaces every time it boots, we can use a systemd unit file along with the sudo macchanger command. By using the -e option, we can change the MAC address while keeping the three OUI bytes the same, which will prevent any issues with devices that only recognize recognized manufacturer hardware.

We will be creating two separate services, one for the Ethernet connection and another for the Wi-Fi connection. A single unit file will serve as a template for both services. To create the unit file, we need to use sudo and edit a file with the desired base name for our services. The at symbol "@" in the file name will be replaced by the name of the network connection when the service is launched. In this case, our unit file is named "macspoof@.service" as it is used for MAC address spoofing. Copy the provided text into the unit file, save it, and close the editor.

[Unit]

Description=Spoofing MAC address on %I

Wants=network-pre.target

Before=network-pre.target

BindsTo=sys-subsystem-net-devices-%i.device

After=sys-subsystem-net-devices-%i.device

[Service]

sudo systemctl enable macspoof@wlp2s0.service

After restarting our laptop, we can check our current MAC addresses using macchanger. It's worth noting that we don't require sudo privileges as we're not modifying any MAC address settings.

To view the currently active MAC addresses on our network interfaces along with their original MAC addresses, we can use the following commands:

- macchanger enp3s0

- macchanger wlan0

Unleash Your Linux Power: Permanently Alter Your MAC Address


To change your MAC address, most desktop environments have an option to set a new one. In GNOME, go to "Settings," select either "Wi-Fi" or "Network" from the sidebar, and then click on the cogged wheel icon next to the connection you want to modify. From there, go to the "Identity" tab and either enter a new MAC address in the "MAC Address" field or select one from the drop-down menu. The "Cloned Address" drop-down menu also offers several options to choose from.

Preserve your MAC address at boot-time to avoid any changes from the set MAC address. For permanent use, stick to your genuine hardware MAC address. If you prefer to generate a random MAC address, choose the random option. For stability, generate a hashed MAC address that stays the same every time the connection activates. This is useful when you need to hide your hardware MAC address but still require the same IP address from a DHCP router. Keep in mind that any changes made will only take effect upon rebooting or turning the connection off and on again. It's important to note that changing your MAC address is legal as long as you're not using it to impersonate someone else's network device, and your jurisdiction probably has laws in place to address unlawfully receiving network traffic. For instance, the UK has the Computer Misuse Act and the U.S. has the Computer Fraud and Abuse Act.

Be Careful!

Become anonymous by all means, but don’t pretend to be someone else.