How to Change MAC Address in Linux (Two Methods)

The MAC tackle is a singular identifier assigned to each system linked to a community. Though the MAC tackle is everlasting, chances are you’ll need to change it in your system in some instances. For instance, you may change the MAC tackle in your system to cover your id or to resolve community compatibility points. … The post How to Change MAC Address in Linux (Two Methods) appeared first on Ferdja.

May 8, 2023 - 08:00
 1
How to Change MAC Address in Linux (Two Methods)

The MAC tackle is a singular identifier assigned to each system linked to a community. Though the MAC tackle is everlasting, chances are you’ll need to change it in your system in some instances. For instance, you may change the MAC tackle in your system to cover your id or to resolve community compatibility points. With that in thoughts, this information will present you find out how to change the MAC tackle on a Linux system. So whether or not you’re a newbie or an skilled Linux consumer, comply with this information to switch the MAC tackle in a fast and straightforward method.

Altering the MAC Handle in Linux (2023)

What’s MAC Handle?

As talked about above, the MAC Handle (or Media Entry Management tackle) is a singular identifier used to acknowledge gadgets linked to a community. This tackle is used to establish and talk with different gadgets, be it a pc, smartphone, or printer, on a community.

The MAC tackle is a 48-bit hexadecimal tackle consisting of six units of two digits or characters separated by colons or hyphens. It is usually known as the Bodily tackle or Burned-in tackle. That’s as a result of the MAC tackle is assigned by the producer and is burned into the system’s {hardware}. So it often can’t be modified, or at the very least they don’t change on their very own like an IP tackle.

Distinction Between MAC Handle and IP Handle

Every community system wants at the very least two addresses to get acknowledged by different gadgets and community interfaces – one is the MAC tackle, and the opposite is the IP tackle (Web Protocol tackle). Whereas the previous is used to uniquely establish gadgets on a community, the latter helps establish a tool’s connection to the community. Which means an IP tackle makes it simpler to find your system, so the community is aware of the place to ship your information. Furthermore, the IP tackle will get assigned by the Web Service Supplier(ISP), and the MAC tackle is assigned by the producer, as we talked about above.

Nonetheless, we will change the MAC tackle utilizing some neat software program tips, which we’ll study on this article. In contrast to an IP Handle, which could be modified completely, the MAC tackle will get reverted to the unique producer’s tackle whenever you reboot the system.

Why You Might Need to Change the MAC Handle?

There could also be quite a few the reason why you need to change the MAC tackle in your Linux pc. Altering the MAC tackle makes the community gadgets deal with you want a brand new particular person. This could make you utterly nameless on a public community, therefore, defending you from cyberattacks on a public community. You may as well get entry to limitless free public Wi-Fi at airports, cafes, and so on., by altering your system’s MAC tackle.

The MAC tackle change may also be used for some unlawful actions, reminiscent of impersonating the admin of a company. By altering your MAC tackle to that of the admin, you may achieve unlawful entry to restricted networks. Nonetheless, we condemn any such malicious actions and advise in opposition to them.

Putting in Bundle to Change MAC Handle in Linux

There are a number of Terminal instruments, reminiscent of macchanger, net-tools, and so on., that may allow you to change the MAC tackle in your Linux PC. Right here, now we have listed the Linux instructions to put in each packages, so comply with alongside.

To put in macchanger and net-tools packages on a Debian-based system, use the next command:

sudo apt set up macchanger net-tools

For CentOS-based techniques, use the next command to put in the packages:

sudo yum set up macchanger net-tools

To put in the 2 packages in Arch-based techniques, use the next command:

sudo pacman -S macchanger net-tools

Whereas putting in the macchanger package deal, it shows a immediate asking customers whether or not they want to change the MAC tackle each time they boot into the system or not. Use the arrow keys to navigate the alternatives. Select both Sure or No, relying in your choice. Then, hit Enter to verify your alternative.

macchanger prompt during installation in Linux

The best way to Change the MAC Handle Briefly

Step 1: Checking for Community Units

Earlier than you alter the MAC tackle, you want to know what’s the identify of the system and its present MAC tackle. To checklist all of the community gadgets current in your system, use this command:

ifconfig

How to Change MAC Address in Linux

For older techniques or in case of any errors, use the next command:

ip addr present

How to Change MAC Address in Linux

If you run the command, the primary a part of the output shows the Loopback tackle data, which could be acknowledged with the lo label and is used for diagnosing any issues within the community.

The second half reveals particulars in regards to the community interface, which is eth0 on this instance. Moreover, the ether sub-label specifies the {hardware} tackle or the MAC tackle, which is 08:00:27:05:10:68 in our case. The inet sub-label specifies the IPv4 IP tackle and the inet6 sub-label specifies the IPv6 IP tackle.

Step 2: Disabling the Community Machine

Now that you’ve got famous your community interface identify, you first must disable the system’s connection to the community to vary its MAC tackle in Linux. Disable the system utilizing the next command:

sudo ifconfig down

How to Change MAC Address in Linux

If you run this command, you’re going to get disconnected from the web. If the above command doesn’t work in your system, you may both reinstall the net-tools package deal or use the next command:

sudo ip hyperlink set dev down

How to Change MAC Address in Linux

Step 3: Altering the MAC Handle

After you will have disabled the system’s community connection, now you can change the MAC tackle. Use the next command to vary the MAC tackle in Linux.

sudo ifconfig down hw ether

Then, you may allow the system once more utilizing this command. Run the instructions to ensure that the specified consequence.

sudo ifconfig up

How to Change MAC Address in Linux

In case of any errors, use the next command to vary the MAC tackle and allow the system’s community connection:

ip hyperlink set dev tackle

ip hyperlink set dev up

Step 4: Verifying the Modifications Made

To confirm that the MAC tackle of your Linux system has modified efficiently, run the next command:

ifconfig

verifying new mac address

And in case of any errors or in case your system is outdated, use the next command:

ip addr present

The best way to Change the MAC Handle Completely

Step 1: Checking for Community Machine

Just like the earlier part, you first must checklist all of the community gadgets within the system and be aware down the interface identify utilizing the next command:

ifconfig

listing network devices

To see the present MAC tackle of the community interface, use the next command:

sudo macchanger --show

checking the current mac address

Step 2: Assigning A New MAC Handle

When utilizing the macchanger instrument to vary the MAC tackle completely, you do not want to disable the system community connection and re-enable it. You possibly can immediately assign a random MAC tackle to your PC utilizing the next command:

sudo macchanger -r

changing the mac address using macchanger

To assign a selected MAC tackle in Linux use the command beneath. You will have to specify the MAC tackle (6 units of two digits or characters separated by colons) you want to assign to your Linux system. Here’s what the syntax appears to be like like:

sudo macchanger --mac=

For instance, now we have modified the mac tackle to 00:00:00:31:33:73 for the interface eth0 utilizing the command beneath.

sudo macchanger --mac=00:00:00:31:33:73 eth0

assigning a specific mac address for eth0 interface

Step 3: Making Modifications Everlasting

1. To get a brand new MAC tackle every time you boot into the system, you may create a /and so on/systemd/system/changemac@.service systemd unit file utilizing a Linux textual content editor of your alternative. For that, kind the next command within the Terminal:

sudo vim /and so on/systemd/system/changemac@.service

2. Then, paste the next textual content contained in the changemac@.service file:

[Unit]
Description=adjustments mac for %I
Desires=community.goal
Earlier than=community.goal
BindsTo=sys-subsystem-net-devices-%i.system
After=sys-subsystem-net-devices-%i.system

[Service]
Sort=oneshot
ExecStart=/usr/bin/macchanger -r %I
RemainAfterExit=sure

[Install]
WantedBy=multi-user.goal

Within the above piece of code, a brand new MAC tackle is assigned to the community interface each time you boot your Linux pc. You possibly can add a selected MAC tackle utilizing the -m choice as a substitute of -r within the tenth line, as proven beneath:

ExecStart=/usr/bin/macchanger -m XX:XX:XX:XX:XX:XX %I

How to Change MAC Address in Linux

3. Subsequent, all you want to do is allow the service you simply created utilizing the next command:

sudo systemctl allow changemac@.service

How to Change MAC Address in Linux

Now, you might be all set. Your Linux pc will robotically change the MAC tackle (completely) to a brand new one each time you boot into a brand new session.

Continuously Requested Questions

Are MAC addresses everlasting?

Sure, MAC Addresses are everlasting and get assigned by the producer of the community system. However they are often modified utilizing some tips within the Linux terminal, as proven above.

Do MAC addresses get reused?

Because the variety of out there MAC addresses is proscribed, producers do must reuse the MAC addresses.

How lengthy is a MAC tackle?

A MAC tackle consists of 48 bits or 6 bytes, the place every byte consists of two hexadecimal digits. They’re proven in units of two, separated by a colon or hyphen.

Modify the MAC Handle in Linux

Altering the MAC tackle in Linux is straightforward and can assist enhance your privateness and safety whereas utilizing the Web. Whereas you want to use the Terminal to switch the MAC tackle completely, be aware that the steps would possibly differ barely relying in your Linux distro. Additional, whereas altering the MAC tackle in your Linux PC, make sure that it doesn’t battle with another MAC tackle, or else each addresses will get disconnected from the community. We hope this text helped you completely change your MAC tackle in your Linux PC. When you have any questions, tell us within the feedback beneath.

The post How to Change MAC Address in Linux (Two Methods) appeared first on Ferdja.