How to Change MAC Address in Linux
Changing the MAC address in Linux is quite a straightforward process only if you know the right way of doing it. If you don’t know how to do it, don’t worry I got y’all covered today, today in this informative guide I will be showing you how to change MAC address in Linux in the simplest possible way.
Every device connected to a network is given a specific identifier called a MAC address. Although the MAC address is persistent, there are situations in which you might want to modify it on your device.
You can modify your device’s MAC address, for instance, to conceal your identity or to fix network compatibility problems. In light of this, this article will explain how to change the MAC address of a Linux device.
Hence, regardless of your level of knowledge of Linux, use this method to quickly and simply change the MAC address.
MAC Address- What is it?
As was already noted, MAC addresses, also known as Media Access Control addresses, are distinctive identifiers used to identify devices connected to a network. Whether it’s a computer, smartphone, or printer, this address is used to locate and connect to other networked devices.
Six sets of two digits or characters, separated by colons or hyphens, make up the 48-bit hexadecimal MAC address. Other names for it are the Physical address and the Burned-in address. This is the case because the manufacturer assigns the MAC address and burns it into the hardware of the product. As a result, they are typically immutable or at the very least, do not alter on their own, like an IP address.
The Steps to change MAC Address in Linux permanently
- Examining network devices
- Using the same command as in the prior section, you must first list every network device on the system and record the name of each interface.
ifconfig
- Use the following command to view the network interface’s present MAC address:
sudo macchanger – – show <interface_ name>
- A New MAC Address Is Assigned
- There is no need to turn off and turn back on the device’s network connection when using the macchanger programme to change the MAC address permanently. With the following command, you can instantly give your System a random MAC address:
sudo macchanger – – r <interface_ name>
- Use the following command to allocate a specific MAC address in Linux. To assign a MAC address to your Linux system, you must provide six sets of two digits or characters, separated by colons. This is how the syntax appears:
Sudo macchanger – – mac= <mac _ address> < interface_name>
- Making Changes Permanent
- You may use your preferred Linux text editor to create a systemd unit file called /etc/systemd/[email protected] that will give you a new MAC address each time you boot the system. In order to do it, enter the following command into the Terminal:
sudo vim /etc/systemd/system/[email protected]
- Paste the following text into the [email protected] file after that:
[Unit]
Description=changes mac for %I
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
[Service]
Type=oneshot
ExecStart=/usr/bin/macchanger -r %I
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
You are now ready to go. Each time you boot into a new session on your Linux machine, the MAC address will automatically change to a new one (permanently). Do refer to this article before modifying it.
Conclusion
So that’s how you change the MAC address on Linux, it was that simple, right? well there are different methods also available to change MAC address but the method shared in this article is the easiest and simplest way of doing things.
Got any queries in mind, don’t hesitate to comment down below and I will solve your all queries in shortest time possible.