As Linux users, we sometimes need to change the MAC address of our network adapters. This process is also called spoofing or faking a MAC address. This article explains how to change a MAC address through an Ubuntu 18.04 LTS system.
MAC, that stands for Media Access Control, is a six byte ID permanently embedded in the firmware of a network adapter. This address can be read by an operating system and network where the adapter is installed. All network nodes such as workstations and printers etc. are identified by these MAC addresses over the network. These addresses are not identical, even for two similar device models of the same manufacturer. All MAC addresses need to follow the standards set by IEEE, the Institute of Electrical and Electronics Engineers.
So why do we need to change a MAC address? There are mainly the following two reasons to change it:
In order to view the MAC addresses of all your network devices, you can use the following command on your Ubuntu terminal:
$ ip link show
Tip: You can open the Terminal through the Ctrl+Alt+T shortcut
The above output from my system shows MAC addresses of three network devices installed on my system. The part after “link/ether” is where you will see the MAC address of a particular device but we have blurred it for privacy reasons.
There is another way to view MAC addresses, but you may first need to install net-tools on your system through the following command:
$ sudo apt install net-tools
Then, run the following command:
$ ifconfig | grep ether
In order to change the MAC address of a device, you first need to install a command line utility called the macchanger.
Open the Terminal either through the Dash or the Ctrl+Alt+T shortcut and then run the following command:
$ sudo apt-get install macchanger
During the installation process, you will encounter the following configuration message:
Select Yes through the arrow keys and then press Enter in order to configure macchanger to run automatically whenever a network device is brought up or down.
The following command will let you get the interface-name of a device that you will be using later to change its MAC address:
$ ip addr
The highlighted interface-name is the one we will be using in our following examples.
The following command will assign a random, but viable, MAC id to your network adapter:
Sytnax:
$ macchanger -r <interface-name>
Example:
$ macchanger -r enp37s0
The following command will assign a specific MAC id to your network adapter:
Sytnax:
$ macchanger --mac=XX:XX:XX:XX:XX:XX <interface-name>
If you need to restore the MAC address of a device to its original state, you can use the following command:
Syntax:
$ macchanger -p <interface-name>
Example:
macchanger -p enp0s3
Through the simple steps described in this article, you can view and change your Mac addresses and also restore them to the original ones whenever needed.
Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…
ISPConfig is an open-source control panel that allows users to manage multiple servers from a…
As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…
Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…
Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…
phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…