Categories: CentOSLinuxShell

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

# 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.

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.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago