Cyberithub

How to Change the MAC Address on Ubuntu 20.04 LTS Using Macchanger

Advertisements

In this article, I will take you through the steps to change the MAC Address on Ubuntu 20.04 LTS using macchanger but before that let me ask you a quick question. Did you ever tried to change MAC Address on a Linux System ? If you never tried then let me tell there are few ways using which you can change the MAC Address of an interface in your Linux based system.

One such way is through macchanger utility. It is a free and open source utility available in multiple Linux flavors that can be easily used to change the MAC Address of an interface. Not only that you can also revert back to original MAC Address using just a simple command. We will see the installation steps of this utility on Ubuntu 20.04 LTS Server in below section. More about Macchanger utility.

Advertisements

What is MAC Address

MAC Address is also known as Media Access Control Address. It is a unique 48-bit address assigned to a Network Interface Controller(NIC).

How to Change the MAC Address on Ubuntu 20.04 LTS Using Macchanger

Steps to Change the MAC Address on Ubuntu 20.04 LTS Using Macchanger

Also Read: 8 Popular Steps to Install Laravel on Ubuntu 20.04 LTS

Advertisements

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS Server.

b) You should have sudo or root access to run privileged commands.

Advertisements

c) You should have apt or apt-get utility installed in your Server.

 

Step 2: Update Your System

In the very first step you need to update your Server using apt update command. This will download and install all the latest versions.

Advertisements
root@localhost:~# apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:4 https://packages.microsoft.com/repos/edge stable InRelease [7,343 B]
Get:5 http://in.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [549 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,284 kB]
Ign:7 http://ppa.launchpad.net/oguzhaninan/stacer/ubuntu focal InRelease
Get:8 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:9 http://in.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [268 kB]

 

Step 3: Install Macchanger

In the next step you can install Macchanger tool by using apt install macchanger -y command as shown below.

root@localhost:~# apt install macchanger -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libegl1-mesa libxcb-xinerama0 libxcb-xtest0 linux-headers-5.8.0-55-generic linux-hwe-5.8-headers-5.8.0-55 linux-image-5.8.0-55-generic
linux-modules-5.8.0-55-generic linux-modules-extra-5.8.0-55-generic
Use 'apt autoremove' to remove them.
The following NEW packages will be installed:
macchanger
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 191 kB of archives.
After this operation, 651 kB of additional disk space will be used.

 

Step 4: Check Macchanger Version

If you want to check the current installed version of macchanger then you need to use macchanger --version command as shown below. As you can see the current version is 1.7.0.

root@localhost:~# macchanger --version
GNU MAC changer 1.7.0
Written by Alvaro Lopez Ortega <alvaro@gnu.org>

Copyright (C) 2003,2013 Alvaro Lopez Ortega <alvaro@gnu.org>.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 

Step 5: Check Current MAC Address

To get the information of all the network interfaces available in your System, you need to use ip addr sh command. So as you can see from the output, currently we have two network interfaces available in our system - lo and enp0s3. Similarly, you can check in your System.

root@localhost:~# ip addr sh
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:c3:e3:20 brd ff:ff:ff:ff:ff:ff
inet 192.168.29.113/24 brd 192.168.29.255 scope global dynamic enp0s3
valid_lft 3281sec preferred_lft 3281sec
inet6 2405:201:a40a:e905:a00:27ff:fec3:e320/64 scope global dynamic mngtmpaddr
valid_lft 3599sec preferred_lft 3599sec
inet6 fe80::a00:27ff:fec3:e320/64 scope link
valid_lft forever preferred_lft forever

If you want to check the MAC address of interface enp0s3 then you need to use macchanger -s enp0s3 command as shown below.

How to Change the MAC Address on Ubuntu 20.04 LTS Using Macchanger 2

 

Step 6: Change the MAC Address Randomly

If you want to change the MAC Address of an interface randomly then you need to use macchanger -r <interface> syntax. In this example, we are changing the MAC address of network interface enp0s3 using macchanger -r enp0s3 command as shown below.

How to Change the MAC Address on Ubuntu 20.04 LTS Using Macchanger 3

 

Step 7: Change the MAC Address Manually

To change the MAC Address of an interface manually you need to use macchanger -m <new_mac_address> <interface> syntax. In this example, we are changing the MAC address of interface enp0s3 to b2:ee:83:a7:c7:b4 using macchanger -m b2:ee:83:a7:c7:b4 enp0s3 command as shown below.

How to Change the MAC Address on Ubuntu 20.04 LTS Using Macchanger 4

If you verify the Address again by using macchanger -s enp0s3 command then you can see that it is indeed changed.

How to Change the MAC Address on Ubuntu 20.04 LTS Using Macchanger 5

 

Step 8: Restore Interface MAC Address Back to Original

Sometimes you might also think if it is possible to restore the original MAC Address or not. So the answer is yes. You can restore the original MAC address by using macchanger -p enp0s3 command as shown below.

How to Change the MAC Address on Ubuntu 20.04 LTS Using Macchanger 6

 

Step 9: How to Check all the options available with macchanger 

If you want to check all the options available with macchanger command then you need to use macchanger --help as shown below.

root@localhost:~# macchanger --help
GNU MAC Changer
Usage: macchanger [options] device

-h, --help Print this help
-V, --version Print version and exit
-s, --show Print the MAC address and exit
-e, --ending Don't change the vendor bytes
-a, --another Set random vendor MAC of the same kind
-A Set random vendor MAC of any kind
-p, --permanent Reset to original, permanent hardware MAC
-r, --random Set fully random MAC
-l, --list[=keyword] Print known vendors
-b, --bia Pretend to be a burned-in-address
-m, --mac=XX:XX:XX:XX:XX:XX
--mac XX:XX:XX:XX:XX:XX Set the MAC XX:XX:XX:XX:XX:XX

Report bugs to https://github.com/alobbs/macchanger/issues

 

Step 10: Remove Macchanger 

Once you are done with the Macchanger, you can remove it from the Server by using apt remove macchanger -y command as shown below.

root@localhost:~# apt remove macchanger -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libegl1-mesa libxcb-xinerama0 libxcb-xtest0 linux-headers-5.8.0-55-generic linux-hwe-5.8-headers-5.8.0-55 linux-image-5.8.0-55-generic
linux-modules-5.8.0-55-generic linux-modules-extra-5.8.0-55-generic
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
macchanger
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 651 kB disk space will be freed.
(Reading database ... 237573 files and directories currently installed.)
Removing macchanger (1.7.0-5.4) ...
Processing triggers for install-info (6.7.0.dfsg.2-5) ...
Processing triggers for man-db (2.9.1-1) ...

Leave a Comment