How to change the MAC Address on CentOS 8

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

ip link show

# ifconfig | grep ether

ifconfig | grep ether

These commands will display the hardware address of your network interface card. Sample output is attached below for reference.

MAC Address

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

Shutdown network card

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

ip link set dev

Finally, turn on the interface with the following command.

# sudo ip link set dev ens37 up

Enable network card

Now, verify the new MAC address by using the following command.

# ip link show ens37

show network card details

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

Edit network config file

Add/Edit the MACADDR according to your own MAC address.

Network card configuration

Exit and save the configuration file and restart the network, using the following command.

# sudo systemctl restart network

Restart network

Again, verify the new MAC address.

Conclusion

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.