macchanger prompt during installation in Linux

How to Change MAC Address in Linux (Two Methods)

[ad_1]

The MAC tackle is a singular identifier assigned to each machine related to a community. Even although the MAC tackle is everlasting, you might have considered trying to change it in your machine in some instances. For instance, you may change the MAC tackle in your machine to conceal your id or to resolve community compatibility points. With that in thoughts, this information will present you the way to change the MAC tackle on a Linux machine. So whether or not you’re a newbie or an skilled Linux consumer, observe this information to modify the MAC tackle in a fast and simple method.

Changing the MAC Address in Linux (2023)

What is MAC Address?

As talked about above, the MAC Address (or Media Access Control tackle) is a singular identifier used to acknowledge units related to a community. This tackle is used to establish and talk with different units, 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 can be referred to because the Physical tackle or Burned-in tackle. That’s as a result of the MAC tackle is assigned by the producer and is burned into the machine’s {hardware}. So it often can’t be modified, or at the least they don’t change on their very own like an IP tackle.

Difference Between MAC Address and IP Address

Each community machine wants at the least two addresses to get acknowledged by different units and community interfaces – one is the MAC tackle, and the opposite is the IP tackle (Internet Protocol tackle). While the previous is used to uniquely establish units on a community, the latter helps establish a tool’s connection to the community. That means an IP tackle makes it simpler to find your machine, so the community is aware of the place to ship your knowledge. Moreover, the IP tackle will get assigned by the Internet Service Provider(ISP), and the MAC tackle is assigned by the producer, as we talked about above.

However, we will change the MAC tackle utilizing some neat software program methods, which we’ll study in this text. Unlike an IP Address, which might be modified completely, the MAC tackle will get reverted to the unique producer’s tackle while you reboot the machine.

Why You May Want to Change the MAC Address?

There could also be quite a few the explanation why you need to change the MAC tackle in your Linux laptop. Changing the MAC tackle makes the community units deal with you want a brand new particular person. This can make you fully nameless on a public community, therefore, defending you from cyberattacks on a public community. You may also get entry to limitless free public Wi-Fi at airports, cafes, and so on., by altering your machine’s MAC tackle.

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

Installing Package to Change MAC Address in Linux

There are a number of Terminal instruments, akin to macchanger, net-tools, and so on., that may allow you to change the MAC tackle in your Linux PC. Here, we now have listed the Linux instructions to set up each packages, so observe alongside.

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

sudo apt set up macchanger net-tools

For CentOS-based methods, use the next command to set up the packages:

sudo yum set up macchanger net-tools

To set up the 2 packages in Arch-based methods, use the next command:

sudo pacman -S macchanger net-tools

While putting in the macchanger bundle, 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. Choose both Yes or No, relying in your desire. Then, hit Enter to affirm your alternative.

macchanger prompt during installation in Linux

How to Change the MAC Address Temporarily

Step 1: Checking for Network Devices

Before you alter the MAC tackle, you want to know what’s the title of the machine and its present MAC tackle. To listing all of the community units current in your system, use this command:

ifconfig

How to Change MAC Address in Linux

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

ip addr present

How to Change MAC Address in Linux

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

The second half reveals particulars concerning the community interface, which is eth0 in this instance. Furthermore, 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 Network Device

Now that you’ve got famous your community interface title, you first have to disable the machine’s connection to the community to change its MAC tackle in Linux. Disable the machine utilizing the next command:

sudo ifconfig <interface_name> down

How to Change MAC Address in Linux

When you run this command, you’ll get disconnected from the web. If the above command doesn’t work in your system, you may both reinstall the net-tools bundle or use the next command:

sudo ip hyperlink set dev <interface_name> down

How to Change MAC Address in Linux

Step 3: Changing the MAC Address

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

sudo ifconfig <interface_name> down hw ether <new_mac_address>

Then, you may allow the machine once more utilizing this command. Run the instructions in order for the specified end result.

sudo ifconfig <interface_name> up

How to Change MAC Address in Linux

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

ip hyperlink set dev <interface_name> tackle <new_mac_address>

ip hyperlink set dev <interface_name> up

Step 4: Verifying the Changes 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

How to Change the MAC Address Permanently

Step 1: Checking for Network Device

Like the earlier part, you first want to listing all of the community units in the system and observe down the interface title 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 <interface_name>

checking the current mac address

Step 2: Assigning A New MAC Address

When utilizing the macchanger software to change the MAC tackle completely, you do not want to disable the machine community connection and re-enable it. You can instantly assign a random MAC tackle to your PC utilizing the next command:

sudo macchanger -r <interface_name>

changing the mac address using macchanger

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

sudo macchanger --mac=<mac_address> <interface_name>

For instance, we now 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 Changes Permanent

1. To get a brand new MAC tackle every time you boot into the system, you may create a /and so on/systemd/system/[email protected] systemd unit file utilizing a Linux textual content editor of your alternative. For that, sort the next command in the Terminal:

sudo vim /and so on/systemd/system/[email protected]

2. Then, paste the next textual content contained in the [email protected] file:

[Unit]
Description=modifications mac for %I
Wants=community.goal
Before=community.goal
BindsTo=sys-subsystem-net-devices-%i.machine
After=sys-subsystem-net-devices-%i.machine

[Service]
Type=oneshot
ExecStart=/usr/bin/macchanger -r %I
StayAfterExit=sure

[Install]
WantedBy=multi-user.goal

In the above piece of code, a brand new MAC tackle is assigned to the community interface each time you boot your Linux laptop. You can add a particular MAC tackle utilizing the -m choice as an alternative of -r in 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. Next, all you want to do is allow the service you simply created utilizing the next command:

sudo systemctl allow changemac@<interface_name>.service

How to Change MAC Address in Linux

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

Frequently Asked Questions

Are MAC addresses everlasting?

Yes, MAC Addresses are everlasting and get assigned by the producer of the community machine. But they are often modified utilizing some methods in the Linux terminal, as proven above.

Do MAC addresses get reused?

Since the variety of obtainable MAC addresses is restricted, producers do want to reuse the MAC addresses.

How lengthy is a MAC tackle?

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

Modify the MAC Address in Linux

Changing the MAC tackle in Linux is easy and can assist enhance your privateness and safety whereas utilizing the Internet. While you want to use the Terminal to modify the MAC tackle completely, observe that the steps would possibly fluctuate barely relying in your Linux distro. Further, whereas altering the MAC tackle in your Linux PC, be sure 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. If you will have any questions, tell us in the feedback beneath.

[ad_2]


Comments

Leave a Reply

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