How to change or spoof a MAC Address in Ubuntu and Linux Mint

When connecting to external Wi-Fi networks, privacy is required. By changing your MAC address, you can make sure that no one can trace or track you.

Computer networking is primarily based on IP addresses. To explain the relevance of IP address, we’re going to briefly describe how these networks work with the example of the internet.

Functioning of Networks

When we have a device connected to the internet, and we enter the URL of a website, say ‘www.fosslinux.com,’ what we are doing is asking the internet to search for the server of ‘FOSS Linux,’ and request them to share their data with us. This part of the process is called ‘request.’

Later, the server detects the request and analyzes whether to, or whether not to share the data. If yes, it sends a webpage to the system that requested it, and that is how we can see the homepage of a website. This part is called the ‘response.’ This whole process is repeated again and again with every link we click, and every website we visit.

All well and good. But how does it reach the target server/system? An IP address is a reference that the internet uses to reach a website server or your system. We can use the analogy of a mail letter here. Sending a letter to someone requires an address, and so does posting a reply to that very letter. In that case, it requires the geographical address, while in the case of computers, it requires the IP address.

The IP address, though, only helps data to go as far as the router that the system is connected. After that, the router requires the MAC address of the exact system (that is currently connected to that router) to route the data to that system. That is how you obtain the data on the internet.

MAC addresses Usage

With all that explained, the basic idea is that the MAC address is a unique number or address that can be used to identify your system correctly. Our systems can interact with the networks using network cards of some sort or the other. There are most commonly wireless cards (for Wi-Fi) and ethernet cards (for wired connections). All the network cards in the world have a unique MAC address.

Why you might want to change your MAC address

  • For privacy – When connecting to external Wi-Fi networks, privacy is required. By changing your MAC address, you can make sure that no one can trace or track you.
  • For using specific services – Some services are bound to work on only a particular range of MAC addresses. You can change your MAC address to whatever you desire, and you can then use that service.

View MAC Address

To view the MAC address on your system, we will describe two commands, and you can use any of them. If one doesn’t work on your system, the other one definitely will.

IP command

Use this command:

ip link

It gives information about the networking hardware of a system. It will contain information of all the interfaces available and have the MAC address next to the part saying ‘link/ether‘ for each interface.

IP command.
IP command

ifconfig

Next, you can use the Swiss-Army knife of network interface tools, ifconfig to view your networking hardware information. Use this command:

ifconfig -a

The output is a little messier but has way more information. But just because it is more powerful and shows more information, doesn’t mean that its better. If you wish to find out the MAC address, and general information, the ip command is better in my opinion, because it shows more streamlined and to-the-point information.

ifconfig output.
ifconfig output

In the output of ifconfig, you’ll find information categorized according to the interface. The MAC address, here too, is next to the word ‘ether‘ for various interfaces.

Changing MAC Address

Prerequisite

IMPORTANT:: Before changing the MAC address, you have to switch it off. To do that, you must first know the name of the network interface on your device. Use the same commands as above, ip or ifconfig, and you’ll get a list of network interfaces in both.

If its a wired connection, it will have the part ‘eth‘ or ‘enp‘ in the interface name. If wireless, it will have ‘wlan‘ or ‘wlp‘ in the name. The key element is ‘e’ for wired, and ‘w’ for wireless. For example, here:

IP command.
IP command

enp1s0‘ means wired connection, and ‘wlp2so‘ means wireless connection.

Now, to turn it off, use this command:

sudo ifconfig <interface name> down

If you do not have ifconfig installed, install it using:

sudo apt-get install net-tools

Now for the main task, a program that helps change the MAC address very quickly. The tool is called macchanger (the name says it all). Install it using:

sudo apt-get install macchanger

You will get a prompt asking whether you want to automatically reset the MAC address each time you connect/disconnect utilizing a network interface. Choose as you desire.

MACChanger prompt
MACChanger prompt

Changing the MAC address to a random value

To change the MAC address to a random value, use the following command:

sudo macchanger -r <interface name>

Setting a random MAC address.
Setting a random MAC address

The output will be shown, with the previous and the current MAC address.

Changing the MAC address to a specific value

To change it to a particular number, you must enter the command in the following format:

sudo macchanger -m xx:xx:xx:xx:xx:xx <interface name>

Setting a specific MAC address.
Setting a specific MAC address

Enter whatever address that you desire instead of ‘xx:xx:xx:xx:xx: xx.’ make sure that the length and format are exact.

Restore original MAC address

To restore the original, or ‘permanent’ MAC address, use the following command:

sudo macchanger -p <interface name>

Restoring original MAC address.
Restoring original MAC address

It will change your MAC address to the original MAC address of your hardware.

Conclusion

That is all you will ever need to change your MAC address. Just as a caution, do not misuse this freedom that Linux provides you, to create a nuisance. You can be comparatively safer by changing your MAC address, but not invincible. Even after changing the MAC address, you must keep yourself secure on public networks.

Pulkit Chandak
Pulkit Chandak is a Linux enthusiast and has been using and experimenting with open source software and hardware too since a long time. He is a huge admirer of open source software and wants to ventilate it to all around him. He is interested in reviewing and writing tutorials on Linux and its many distributions. He believes that freedom in software leads to freedom of the mind from the chains of limits.

4 COMMENTS

  1. after you’ve changed your MAC address, be sure to input sudo service network-manager restart to enable your network.

  2. Great tutorial until the next Bump. Any wisdom for changing the mac address while using a vpn? My vpn takes over parameters for mac…

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,421FansLike
377FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

5 Ways to Check the Linux Version

When most people talk of Linux, they are always referring to a Linux distribution. However, this is not the case. Linux itself is a kernel which acts as a bridge between user applications and the hardware. When we talk of a Linux distribution, we refer to an operating system developed from the Linux kernel. A distribution comes with a package manager, pre-installed applications, a Desktop Environment, and several more features.

Getting Started with Linux Operating System

The Linux operating system brings forth a vibrant mix of features and security, making it the best alternative to macOS or Windows operating systems. In this post, we will give you a master guide on Getting started with Linux systems - taking you from a complete beginner to a level where you can begin testing the various Linux distributions available with much ease.

How to Create a Comprehensive Mail Server on Ubuntu

Postal is a free and open-source mail server used to send and receive emails. It comes loaded with tons of excellent features and functionalities, making it extremely popular among large organizations as well as in enterprise settings.

The 10 Best Linux Performance Monitoring Tools

Do you want to monitor the performance of your Linux system? Are you looking for some powerful performance monitoring tools to help you out? If you agree, it's your day as we have put together a detailed list of the ten best Linux performance monitoring tools.

How to Boot your Windows or Linux PC from a USB Drive

Sometime back, the process of installing an operating system required users to pop a bootable media disk into their DVD or CD drive and use it to boot the PC. But times have changed. Nowadays, the most common way of installing an OS is booting from a USB drive. The use of USB drives is further propelled by the current production of slim and lightweight laptops with no support for DVD/CD drives.

Python For Loop: Everything You Need to Know

Loops are one of the essential elements in any programming language, and Python is not an exception to it. Loops are used to repeat a statement or a block of statements multiple times. If there were no concept of loops in programming languages, we have to write each statement again and again for the number of times we want to execute it.

MUST READ

Buyers who wish to go for a machine that is based on Linux often show interest in Chromebooks due to the form factor and extended battery life capabilities. Although ChromeOS power these machines, users can still miss out on a more genuine Linux experience. For those who happen to agree, the new Lemur Pro by System76 might get some heads turning.
Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.

CopyQ – Advanced clipboard manager for Linux

We have all had that moment when we copied a text, but we first needed another one, and in the process, lost the first one. If you're lucky, you can get it back quickly with a bit of work.

Installing an updatable Manjaro Linux on a USB Flash Drive

In this tutorial, we will show step by step how to install a Manjaro on a USB flash. For those new to this distro, it is a light-weight distro that is based on Arch Linux. Arch Linux is known for its simplistic approach and is typically made for Linux pros, but Manjaro bridges the gap between user-friendliness and rock-solid performance.

6 Best Linux Distributions for Beginners

Making the shift to Linux is not as complicated as some people make it out to be. There is a variety of Linux distributions available that cater to the needs of people who are planning on making the jump to Linux from any other operating system.

6 Essential Command-Line Utilities Every Linux User Should Know

Last week, we shared with you several "cool and fun" commands to get comfortable and confident with the Linux command-line. In our quest to further aid Linux users with mastery of the command line, or CLI, we present you with a variety of command-line utilities essential for all Linux users, regardless of proficiency level.