How To Change MAC Address
In this article, you will learn, How to change the MAC address on Linux.
There are many reasons to change the real or physical MAC address of a Network Card in a Computer. It may be you don’t want to show the actual MAC address to the public network. Also, it may be the reason that your System Administrator has blocked the MAC address in the router.
So, for the security concern, it is a good practice to change the actual MAC address with the virtual one. This process is also known as Spoofing MAC address.
In this article, How to change the MAC Address On Linux, I am going to talk about two different ways to change it. So let’s start with the first one.
Method I: Changing the MAC Address Using The Macchanger
Firstly, we are going to use the Macchanger package to change the real MAC address. Also, it is the easiest way to change the MAC address of any computer. So let’s start using this method.
Step 1: Find The MAC Address And Network Interface Of Your Computer
In the first step, you are going to find the MAC address of your computer and the Network Interface. So there is an easy command for that, you can find it below.
ip link show
As a result, you can see in the below picture. The network interface name is
eth0 and MAC address is
Step 2: Installing the Macchanger Package
In the second step, you are going to install this package. This package comes default in many Linux distros but if your operating system does not have it then you can install it. And also, you can just try to install it. If it will be there then you will get the message. So you can find useful the below command to install it on different Linux Distros.
If you want to install on Kali Linux, Ubuntu, Linux Mint, or on Debian or Debian-based Distro then you can use the below command.
sudo apt install macchanger
To install on RedHat, CentOS, or Fedora, then you can use the below command.
sudo dnf install macchanger
Also, you can use the below command to install on Manjaro or Arch Linux.
sudo pacman -S macchanger
Note: You will get a prompt asking for a run automatically every time or not. So you can accept as per your choice.
Step 3: How To Change MAC Address Using Macchanger
If you want to change the MAC address then you must know your Network Interface Name. As we have checked in Step 1.
You can also try to get the detail about it using the help command
macchanger --help or detail manual using the command
If you want to assign a random MAC address then you can use the
-r switch. The command will look as below.
sudo macchanger -r eth0
For example, here,
eth0 is the Network Interface Name of my computer. So replace it with your computer Network Interface name.
Also, you can verify it using the below command, it will show you the spoofed MAC address.
ip a show
If you want to use a custom MAC address, For example
xx:xx:xx:xx:xx:xx then you can use the below command.
sudo macchanger --mac=xx:xx:xx:xx:xx:xx
Also, you can replace
xx:xx:xx:xx:xx:xx it as per your custom MAC address.
Step 4: Reverting After Changing The MAC Address To Its Original MAC Address
But if you want to revert the MAC address to its original MAC address then you can use the below command.
sudo macchanger -p eth0
For example, change
eth0 your network interface name.
Method II: Changing the MAC address using the iproute2
Secondly, it is another method to change the MAC address in Linux.
Step 1: Turn Off The Network Card
You have to turn off the network card. So you can use the below command useful for that.
sudo ip link set dev eth0 down
Note: replace the
eth0 with your network interface name.
Step 2: Setting New MAC Address
So now you have to set up the new MAC address using the following command.
sudo ip link set dev eth0 address xx:xx:xx:xx:xx:xx
Note: Replace here
eth0 with your network interface name and
xx:xx:xx:xx:xx:xx with your chosen MAC address.
sudo ip link set dev eth0 up
Step 3: Verifying The New MAC Address
Now, you can verify the new MAC address using the below command.
ip link show eth0
In this tutorial, you learned about How To Change MAC Addresses in Linux. As you can see it is very easy but if you get any problem you can ask me in the comment section.
You can also read about the below topics.
- The hostnamectl command in Linux with examples
- How to setup passwordless ssh login
- Top 20 SSH interview questions and answers
- Changing the Mac Address
How To Change MAC Address | How To Change MAC Address | How To Change MAC Address | How To Change MAC Address | How To Change MAC Address | How To Change MAC Address | How To Change MAC Address |