In this tutorial, the process of changing the MAC address in the Ubuntu operating system is explained, and the uses of the MAC address are separately examined.
MAC is the acronym for Media Access Control and typically refers to these addresses (MAC) that are embedded based on the physical addresses of devices.
How to Change MAC Address
The network interface of every computer or any device that has the ability to connect to the network has a MAC address. MAC addresses are assigned to devices by the factory. However, they can be changed.
You can also read the article “How to Get IP and MAC Address in Ubuntu” to understand how to obtain a MAC address.
Uses of MAC Address
In addition, to use in the network, MAC addresses are often used for other purposes.
Static IP Assignment
Routers have the ability to allow a computer to have a static IP. When a device connects to the network, it always permanently takes a specific IP so that this IP address matches the MAC address.
MAC Address Filtering
Networks can use filtering properties for MAC addresses so that only devices with specific MAC addresses can connect to the network. This is not considered a very strong security tool; because people can forge their MAC addresses!
MAC Authentication
Some Internet Service Providers (ISPs) may require authentication with a MAC address to allow that address to connect to the Internet.
Device Identification
Many public Wi-Fi networks use the device’s MAC address to identify it. For example, a Wi-Fi network at an airport might open access for 30 minutes and then prohibit connection for others except for MAC addresses that have connected within this time frame. Changing the MAC address, in this case, can get you into the prohibited Wi-Fi network!
Device Tracking
Since the MAC address is unique to each device, it can be used for tracking. As you walk around, your smartphones scan the environment to find the nearest available Wi-Fi network; therefore, their MAC addresses are broadcast on the network. A company named Renew London uses city trash cans to track people’s movements based on their MAC addresses. Apple iOS 16 prevents tracking of such devices by using a random MAC address each time it scans a Wi-Fi network.
Remember that every network interface has its own unique MAC address. Therefore, a laptop that has both Wi-Fi and a wired port for network connection will have separate MAC addresses for each of its wireless and wired network interfaces.
Ubuntu
Recent Linux distributions such as Ubuntu typically use Network Manager to provide a user-friendly and graphical way to spoof MAC addresses!
For example, in Ubuntu, you will find the network icon in the top panel of the screen. Click on ‘Edit’ and select the network connection you want to change. Choose ‘Edit’ and then open the ‘Ethernet’ tab. Enter your new MAC address in the ‘Cloned MAC Address’ section and finally save your changes.
Command Line
You can also use an older method for this task. This method involves disabling the network interface by running a command, changing the MAC address, and finally re-enabling the network interface.
First, you must ensure that ‘eth0’ is the name of the network interface for which you intend to change the MAC address.
The MAC address can be changed using the following commands:
sudo ifconfig eth0 down
sudo ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
sudo ifconfig eth0 up
For permanent changes, you need to modify the configuration file /etc/network/interfaces.d/ or /etc/network/interfaces, so the changes remain after the system is booted. Otherwise, after each reset, the MAC address will revert to its original state.
How to install Macchanger on Linux?
The tool called Macchanger is widely available in various Linux distributions. Hence its availability should not be a concern.
To install it, you just need to search for Macchanger with your preferred software manager.
Also, we can install Macchanger from the terminal. To do this, you should open one and run a command according to the Linux distribution you are using.
To install Macchanger in Debian, Ubuntu, and their derivatives, type the following commands:
sudo apt-get install macchanger macchanger-gtk
While for Arch Linux, Antergos, Manjaro, and their derivatives, install the program with:
sudo pacman -S macchanger
If you are using Fedora, CentOS, RHEL, or some of the systems derived from these, you can install it with either of these commands:
sudo yum install macchanger
sudo dnf install macchanger
For openSUSE, install it with the following:
zypper install macchanger
How to use Macchanger in Ubuntu Linux?
To start using this program in our system, the first thing we need to do after installing it is to identify and know our MAC address. For this purpose, we need to open a terminal and execute the following command:
sudo apt install macchanger
During the installation of the mentioned tool, a dialog box will open, asking you if you want the MAC address to change automatically or not. You can choose either option depending on your needs, but we have chosen the “yes” option, as shown in the image below:
After pressing Enter, wait for the installation process to finish.
After successfully installing the macchanger tool on your system, you need to list all the network cards in your system so that you can select the MAC address you want to change. By running the command ‘ip addr’, all the network cards in your system along with their settings, will be displayed. Our objective is to modify the MAC address of the network card labeled as ‘enp0s3’, and we will achieve this by following the steps outlined below.
Before changing the MAC address of the specified network card, we first try to check its current MAC address with the following command:
macchanger –s enp0s3
You should note that instead of ‘enp0s3’, you need to replace it with the name of your own network card.
In this way, the MAC Address is displayed in the command output:
Now we are going to assign a random MAC address to the specified network card by executing the following command:
sudo macchanger -r enp0s3
Well, now we want to manually change the MAC address of the specified network interface.
sudo macchanger –m c2:43:bc:1c:62:01 enp0s3
Finally, we want to retrieve the original MAC Address of the specified network interface using the following command:
sudo macchanger –p enp0s3
When you run the above command, you’ll realize that now the permanent MAC Address and the New MAC Address of the specified network card are identical, which means the MAC address has been successfully retrieved.
How to change the MAC address in Ubuntu Linux
This tutorial will guide you through the process of changing your MAC address on Ubuntu using the Terminal. This process is quite straightforward.
Step 1. Open the Terminal.
Step 2. Log in as root by typing the phrase ‘sudo –i’, then type your password.
Step 3. View your current address by typing the phrase ‘ip link show.’
Step 4. To prevent any potential issues, follow these steps: Type ‘ip link set dev xxxx’:
‘xxxx’ is the name of the device. For example: ‘ip link set dev wlan0.’
Step 5. Change the MAC address. In the terminal, type ‘ip link set dev xxxx address xx:xx:xx:xx:xx:xx.’ Replace ‘xxxx’ with the name of the device and ‘xx:xx:xx:xx:xx:xx’ with the new MAC address. For example, ‘ip link set dev wlan0 address 88:d0:3b:8f:f8:98’
Step 6. Type ‘ip link set dev xxxx up,’ then replace ‘xxxx’ with the name of the device.