Introduction

MAC address (Media Access Control address) is a unique identifier for network devices. For security or privacy reasons, you may need to change this address. In this post, we will explore how to change MAC address in Ubuntu.

What is a MAC Address?

MAC address is a unique identifier assigned to a Network Interface Card (NIC). This 48-bit (6-byte) address is typically displayed in hexadecimal format as XX:XX:XX:XX:XX:XX. The structure of the address is as follows:

  • First 3 bytes: OUI (Organizationally Unique Identifier) representing the manufacturer
  • Remaining 3 bytes: Unique number assigned by the manufacturer

Checking Your MAC Address

Before changing the MAC address, you can check your current address with the following command:

1
ip link show

Or to check information of a specific interface:

1
ip link show dev <interface_name>

The result will look like this:

2: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
    link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff

Here, 00:11:22:33:44:55 is your current MAC address.

How to Change MAC Address: Using macchanger

macchanger is a dedicated tool for changing MAC addresses, offering various options.

1. Installing macchanger

1
2
sudo apt update
sudo apt install macchanger

During installation, you’ll be asked “Automatically change MAC address at boot?” Choose according to your needs.

2. Changing the MAC Address

Changing a MAC address involves three steps:

2.1 Disable the Network Interface

1
sudo ip link set <interface_name> down

Example: sudo ip link set wlp0s20f3 down

2.2 Change the MAC Address

Change to a random MAC address:

1
sudo macchanger -r <interface_name>

Or change to a specific MAC address:

1
sudo macchanger -m XX:XX:XX:XX:XX:XX <interface_name>

2.3 Enable the Network Interface

1
sudo ip link set <interface_name> up

3. Additional macchanger Options

OptionDescriptionExample
-rCompletely random MAC addresssudo macchanger -r wlp0s20f3
-aRandom MAC from same vendorsudo macchanger -a wlp0s20f3
-ARandom MAC of same typesudo macchanger -A wlp0s20f3
-pReset to original MAC addresssudo macchanger -p wlp0s20f3
-mSet specific MAC addresssudo macchanger -m 00:11:22:33:44:55 wlp0s20f3
-sShow MAC address informationsudo macchanger -s wlp0s20f3

Conclusion

Changing MAC address is a useful technique for security and privacy protection. In Ubuntu, you can easily change MAC address using the macchanger tool, and adjust it according to your needs through various options.