Every network interface on your computer—whether it is an Ethernet port or a Wi-Fi card—has a unique physical identifier known as a Media Access Control (MAC) address. While IP addresses change frequently depending on what network you connect to, your MAC address is hard-coded into the hardware by the manufacturer.
However, there are several legitimate reasons why you might need to temporarily change (or “spoof”) your MAC address in Ubuntu. You might need to bypass strict MAC-based filtering on a corporate network, maintain your privacy on a public Wi-Fi hotspot, or troubleshoot complex networking issues.
In this guide, we will show you exactly how to find your current MAC address in Ubuntu Linux, and how to safely spoof it using the terminal.
How to Find Your Current MAC Address
Before you can change your MAC address, you need to know what it currently is, and more importantly, you need to know the logical name of your network interface.
- Open your terminal by pressing Ctrl + Alt + T.
- Type the following command and press Enter:
ip link show
You will see a list of all your network interfaces. Your primary ethernet connection is usually named something like eth0 or enp3s0. Your Wi-Fi card is typically named wlan0 or wlp2s0.
Look underneath the name of your active connection. You will see a string of six pairs of alphanumeric characters separated by colons (for example: link/ether 00:1A:2B:3C:4D:5E). This is your current MAC address. Write down the name of your interface (e.g., wlp2s0) as you will need it for the next step.
How to Change Your MAC Address Temporarily
To change your MAC address, we will use a fantastic, lightweight tool called macchanger. This tool is available directly from the standard Ubuntu repositories.
Step 1: Install Macchanger
Type the following command and press Enter to install the tool:
sudo apt update && sudo apt install macchanger
During the installation, a pink screen may appear asking if you want macchanger to automatically generate a new MAC address every time a network cable is plugged in. For most users, it is safest to select No and manage it manually.
Step 2: Take Your Network Interface Offline
You cannot change the MAC address of a network card while it is actively transmitting data. You must temporarily disable the interface. (Replace wlp2s0 with your actual interface name).
sudo ip link set dev wlp2s0 down
Step 3: Spoof the MAC Address
Now, use macchanger to assign a completely random MAC address to the interface:
sudo macchanger -r wlp2s0
The terminal will output your permanent (hardware) MAC address alongside your newly generated spoofed address, proving the change was successful.
Step 4: Bring the Interface Back Online
Finally, turn your network card back on so you can connect to the internet:
sudo ip link set dev wlp2s0 up
How to Restore Your Original MAC Address
Because this change is done at the software level, it is not permanent. The easiest way to revert to your original, factory-set MAC address is to simply reboot your computer.
Alternatively, if you do not want to restart your machine, you can use macchanger to restore the permanent address instantly.
- Bring the interface down:
sudo ip link set dev wlp2s0 down - Restore the permanent address:
sudo macchanger -p wlp2s0 - Bring the interface back up:
sudo ip link set dev wlp2s0 up
By using macchanger, you can easily control your hardware’s identity, ensuring better privacy on untrusted networks and giving you greater flexibility as a Linux administrator.