If you don’t want to expose your device MAC address while connecting to Public WIFI’s or maybe the firewall or router blocked the specific MAC address, changing of MAC address to access internet service without being exposing the original MAC address. Changing of MAC address is also known as MAC Spoofing or FAKE address. In this tutorial, we will learn how to change the MAC address in CentOS8.
Find the MAC Address on CentOS
To find out the MAC address or hardware address of a network interface, open the terminal and use anyone of the following command.
# ip link show
# ifconfig | grep ether
These commands will display the hardware address of your network interface card. Sample output is attached below for reference.
Changing the MAC Address
We can do this in two methods. Please be careful not to change your mac address with the live network card. If you do this, it will disconnect your network connection. Use this method with an additional network card.
Method 1: using IPRoute2
To change the MAC address of a network card, you have to turn off that network card. Navigate to the terminal and use the following command.
# sudo ip link set dev ens37 down
the word ens37 is the device name of the network card, it might differ on your system. So adjust the command to match your network card device name. Do the same in the following commands.
Next, assign the MAC address of your own choice using the following command.
# sudo ip link set dev ens37 address XX:XX:XX:XX:XX:XX
Finally, turn on the interface with the following command.
# sudo ip link set dev ens37 up
Now, verify the new MAC address by using the following command.
# ip link show ens37
New MAC address has assigned successfully.
Method 2: using the network configuration file
You can also change the MAC address from the configuration file, for this open up the configuration file of that specific interface.
# sudo vim /etc/sysconfig/network-scripts/ifcfg-ens37
Add/Edit the MACADDR according to your own MAC address.
Exit and save the configuration file and restart the network, using the following command.
# sudo systemctl restart network
Again, verify the new MAC address.
In this tutorial, we learned how to change the MAC address of a network card using two different methods and after changing we also verify that new MAC address.