the Internet

You can therefore change the MAC address of your network card in Linux

All network cards, whether Ethernet (wired) or WiFi (wireless) have a 48-bit identifier at the link layer, the MAC address. The MAC address is a set of hexadecimal numbers (6 blocks of two hexadecimal characters) usually separated by a colon. This MAC address is essential for the proper functioning of the local network, since the MAC is used by the ARP protocol to find the different computers on the network, and it is also used in IPv6 networks to configure SLAAC using EUI- 64. Today in RedesZone we are going to explain how to change the MAC address of your network card in Linux systems, ideal for doing it on servers.

The MAC address is stored on the network card (NIC), Ethernet or WiFi. In principle, this MAC cannot be changed because it is a unique identifier of the device in question, there cannot be two MAC addresses in the same segment of the network, as this will cause many problems. The MAC addresses of a certain device (network card, router, switch, access point, IP camera with WiFi) are unique in the world, as they are written directly, in binary form, into the hardware at the time of manufacture. In addition, in the 48-bit MAC address, the first 24 bits identify the manufacturer of the device and the last 24 bits identify the device in question.

A card's MAC address cannot easily be changed permanently, however, in modern operating systems it can be changed at the software level. Users of Linux-based operating systems, for example Debian, can easily change the MAC address of our network card from a terminal using various methods. Next, we will show you how to change the MAC address of our Linux server with the main methods.

Change MAC address on Linux servers with ip link

The iproute2 suite is the one currently used to manage the whole network of a Linux server or operating system, we can change the IP address, the routing, create new secondary routing tables, and we can also change the MAC address of a certain network card very easily and quickly.

The only thing we will have to do is display the current MAC with the following command:

ip link show interfaz

In our case, the interface is "ens33". Then we need to turn off the network card, if we don't turn it off, changing MAC will not work because it is in use.

ip link set dev interfaz down

We change the MAC address with the following command:

ip link set dev interfaz address XX:XX:XX:XX:XX:XX

And we lift the Ethernet network card:

ip link set dev interfaz up

In the following screenshot, you can see the whole process:

This is the easiest and fastest way to change the MAC address, without needing to install anything.

Change MAC address with ifconfig

The ifconfig command has been used for many years to manage the network in Linux operating systems, but nowadays it is no longer used, in case you still use it, we will also help you change the MAC address with this command on.

The first thing to do is to check the current MAC of our network card. To do this, we will open a terminal or a TTY in our system and type:

ifconfig

Once we know the current MAC address of our card, we need to perform the following configurations:

Disable the network card whose MAC address we are going to change:

ifconfig eth0 down

We change the MAC of said card for the one we want (by changing 00: 00: 00: 00: 00: 00 for the MAC in question that we want to establish).

ifconfig eth0 hw ether 00:00:00:00:00:00

We raise the network card again:

ifconfig eth0 up

As you have seen, changing the MAC address is really quick and easy with ifconfig, the same number of commands as with ip link. Remember that ifconfig is no longer installed in the latest versions of Debian and other distributions, in favor of iproute2.

macchanger: automate the change of MAC address

The macchanger program is designed to automate MAC address change and even allows us to generate a completely random MAC address. This program is not installed by default, we have to install it ourselves through the repository:

sudo apt install macchanger

During its installation, it will ask us if we want it to run automatically when activating a network device, to have a new MAC address each time a network cable is connected or the WiFi network is enabled, ideal for always having a different MAC.

To change the MAC address completely randomly on a certain interface, we need to do the following:

macchanger -r interfaz

The program itself will inform us of the current MAC address, the permanent MAC (the one registered on the card) and the new MAC address:

If we check the MAC with ip link show, we will see:

We also have the possibility that the MAC is random, but keeping the first 24 bits (manufacturer):

macchanger -e interfaz

Of course, we can put the MAC address we want in the following way:

macchanger --mac=XX:XX:XX:XX:XX:XX interfaz

Finally, we can put the original MAC of the card:

macchanger -p interfaz

If we run “–help”, we can see the help provided by this program:

We hope that with these three ways that we have taught you, you can change the MAC address of your Ethernet or WiFi card easily and quickly.

Similar items

Leave your comment

Your email address will not be published. Required fields are marked with *

Button back to top