1. Overview

In the world of communication, the MAC (Media Access Control) address plays a vital role as the fingerprint of our device on a network. However, there are situations where a change in identity isn’t only desirable but necessary. In the Linux domain, having the ability to modify the MAC address is a skill worth acquiring.

In this tutorial, we’ll explore the methods to change the MAC address in a Linux system.

2. What Is a MAC Address?

Before diving into the intricacies of changing MAC addresses, let’s briefly understand what they are.

A MAC address is a unique identifier assigned to a network interface card (NIC) for facilitating communication within a network. It’s composed of six pairs of hexadecimal digits, providing a distinctive identity to the device on a network.

While MAC addresses are designed to be static, there could be situations where altering them becomes necessary.

3. Why Change a MAC Address?

There are various reasons one might want to change their MAC address. Some common reasons include:

  • Network Troubleshooting: In some cases, changing the MAC address can be a troubleshooting step to resolve conflicts or connectivity issues on a network.
  • Privacy and Anonymity: Changing the MAC address can enhance our privacy by preventing tracking based on our device’s unique identifier.
  • Security Testing: Security professionals often change MAC addresses during penetration testing or security audits to simulate different devices on a network. This can help simulate different network scenarios and identify potential vulnerabilities.

4. Changing MAC Address – CLI Method

Let’s start by learning how to change the MAC address in Linux using the command-line method.

4.1. Using ip

The ip command in Linux is a powerful tool for configuring and managing network interfaces. The ip command allows users to view and modify various aspects of networking, including IP addresses, routes, and link states.

Firstly, let’s identify the network interface using ip:

$ ip link 
2: eOth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether 64:26:30:d4:1a:12 brd ff:ff:ff:ff:ff:ff
3: wlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
    link/ether 22:e1:4d:f3:a2:e9 brd ff:ff:ff:ff:ff:ff

The ip link command lists all the network interfaces along with details like IP address, interface name, MAC address, and others.

Secondly, we need to temporarily disable the network interface of which we’ll be changing the MAC address:

$ sudo ip link set dev wlan1 down

Once the network interface is down, we can change the MAC address of wlan1:

$ sudo ip link set dev wlan1 address 12:e1:7d:f8:a3:e5

The above command changes the MAC address of the wireless interface wlan1 to 12:e1:7d:f8:a3:e5.

After changing the MAC address of wlan1, we’ll need to up the network interface:

$ sudo ip link set dev wlan1 up

Finally, we can execute the ip link command to verify the change in the MAC address of the wireless interface.

4.2. Using ifconfig

Another method to change the MAC address in Linux is by utilizing the ifconfig command. It’s a classic tool for configuring network interfaces in Linux.

Firstly, let’s see the network interface information like MAC address, IP address, network interface name, and other information using ifconfig:

└─$ ifconfig
eOth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 64:26:30:d4:1a:12  txqueuelen 1000  (Ethernet)
wlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet  netmask  broadcast
        inet6 fe89::d965:48a5:fd64:9256  prefixlen 64  scopeid 0x20<link>
        ether 22:e1:4d:f3:a2:e9  txqueuelen 1000  (Ethernet)
        RX packets 25419  bytes 18613101 (17.7 MiB)

Similar to the ip command, we’ll need to temporarily disable the network interface:

$ sudo ifconfig wlan1 down

Once the interface is down, we can change the MAC address using the ifconfig command:

$ sudo ifconfig wlan1 hw ether 12:e1:7d:f8:a3:e5

Afterward, we need to enable the network interface using the sudo ifconfig wlan1 up command. Likewise, we can use the ifconfig command to confirm the modification of the MAC address for the wireless interface.

4.3. Using macchanger

The macchanger tool is designed to alter the MAC address of a network interface. It provides a straightforward way to change the unique identifier of a device on a network.

Firstly, let’s install macchanger using apt-get if we haven’t already:

$ sudo apt-get install macchanger

Now. we’ll identify the network interface for which we’ll be changing the MAC address by executing the ifconfig command in the Linux terminal.

Similarly, we need to shut down the interface temporarily. For this, we can use both the ifconfig and the ip command as described earlier above.

Let’s change the MAC address using macchanger:

$ sudo macchanger -m 12:e1:7d:f8:a3:e5 wlan1

The command uses macchanger to change the MAC address of the wlan1 network interface to 12:e1:7d:f8:a3:e5. Here -m option in the command specifies the MAC address that we want to set for the network interface.

After changing the MAC address we’ll repeat the same process, i.e., we’ll enable the network interface using the ifconfig or the ip command and verify the change in MAC address.

5. Changing MAC Address – GUI Method

We can also modify the MAC address of the network interface through the GUI method. In this case, our main operating system will be Kali Linux.

Let’s proceed by navigating the Advanced Network Configuration:

Advanced Network Configuration menu in Kali Linux

Next, we’ll select the wireless network to which we’re currently connected. Now, let’s click on the yellow highlighted section to edit the setting and proceed to the Wi-Fi tab, modify the MAC address within the Cloned MAC address section, and then save the changes:

Modify MAC in the Cloned Mac Address section in Kali Linux

Afterward, we need to disconnect the wireless and then re-connect the wireless, and finally execute the ifconfig command to verify the change in MAC address.

6. Conclusion

In this article, we explored both the CLI and GUI methods to change the MAC address in Linux.

Whether we prefer utilizing CLI tools like ip, ifconfig, and macchanger, or the GUI method, understanding these techniques empowers us to adapt our device’s identity to different network scenarios. We should always exercise caution and ensure compliance with applicable laws and policies when changing MAC addresses.

Comments are closed on this article!