Linux mac address set

How to Change Network MAC Address in Linux

Every network interface on your Linux operating system distribution is associated with a unique number called MAC (Media Access Control). The wireless and Ethernet network modules are examples of commonly used network interfaces on a Linux operating system. MAC serves a unique role in identifying these network interfaces through system protocols and programs.

For example, through DHCP (Dynamic Host Control Protocol), a network interface is assigned an IP address by a network router automatically. In this case, the MAC address acts as a reference manual for networking devices like the router so that these devices know the identity of the other network devices they are communicating with or, in this case, assigning IP addresses.

Why Change Your MAC Address?

The MAC address is different from an IP address such that it is hardware-oriented whereas an IP address is software-oriented. Therefore, an IP address can be permanently changed whereas changing a MAC address is only temporary. If you restart your machine it will default to its original manufacturer’s value.

Three prime reasons as to why you might need to temporarily change your MAC address stand out:

  • You do not trust the public network you are using and therefore don’t want your MAC address to be exposed as it can be used to permanently identify your machine whenever you are on a network.
  • A firewall or router has been used to block your original MAC address to deny you access to a specific network.
  • Airport WiFi and other public networks operate on the “Limited Time Access” rule when it comes to gifting free internet to their clients. Changing the MAC address can bypass this limitation.

Install MAC Changer in Linux

This Linux operating system software package will help us meet the objective of this article guide. We need to make sure that macchanger is installed on your Linux distribution.

Reference the following installation commands in regards to your Linux distribution:

$ sudo apt-get install macchanger [On Debian, Ubuntu and Mint] $ sudo yum install macchanger [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo emerge -a sys-apps/macchanger [On Gentoo Linux] $ sudo pacman -S macchanger [On Arch Linux] $ sudo zypper install macchanger [On OpenSUSE]

You are bound to run into the following prompt during the installation process.

Configure Mac Changer in Linux

If you choose yes , all your online presence will be associated with a new MAC address even after a successful system reboot. If you only need to change your MAC address occasionally, you should proceed with an option no .

Wait for the macchanger installation process to complete.

Читайте также:  Все об linux убунта

Changing Linux MAC Address

The use of the macchanger command should be associated with a network interface. The first step is to identify the available interfaces on your network which most of the time include loopback, wireless, and wired.

We will use the following IP command:

Check Linux MAC Address

From the screen capture above, the wireless interface wlp2s0b1 is associated with the MAC address ec:55:f9:55:8a:ab. To temporarily change this MAC address, you will need to be a root user or have sudo privileges on your Linux machine.

To change the above MAC address, we will use the macchanger command together with the -r option and point to the network interface whose MAC address we need to temporarily change.

$ sudo macchanger -r wlp2s0b1

Change MAC Address

To avoid the above [ERROR] that says:

[ERROR] Could not change MAC: interface up or insufficient permissions: Device or resource busy

1. Stop your network manager.

$ sudo service network-manager stop

2. Take down the targeted network interface.

3. Now change your MAC address.

$ sudo macchanger -r wlp2s0b1

Change MAC Address in Linux

4. Restart your network manager and the associated network interface.

$ sudo service network-manager start $ sudo ifconfig wlp2s0b1 up

Let us now recheck the existence of the new MAC address:

Check Linux MAC Address

The temporary new MAC address has been configured and implemented as expected.

If you want your network identity to be associated with a specific MAC address, you can reference the following macchanger command syntax:

$ sudo macchanger -m [your_custom_MAC_address] [Targeted_network_interface]

An example implementation would be:

$ sudo macchanger -m f7:ed:56:0e:aa:b2 enp0s3

Changing the MAC address on a Linux operating system environment gives you the flexibility of bypassing the limitation of various network administration rules and also the anonymity advantage. You get to play by your own network rules.

Источник

Solved: Change MAC Address in Linux [Temp & Persistent]

When it comes to networking, you’ve probably heard of the term MAC addressed a lot. MAC Address is a physical identity assigned to each interface. Now you may wonder when the MAC Address is already assigned to an interface then why would we want to change it? Well there can be a number of scenarios, speaking from my personal experience

  1. We had a very old rack server where we failed to installed RHEL 8 and the MAC address of the interfaces from this server kept changing after every reboot. So we decided to update the PCI ID of each interface using udev rule bundled inside initrd to overcome this issue.
  2. For PXE boot we perform network based installation. Now this should not be a problem when we are using DHCP but if you want to use static IP then you must define the MAC Address of the interface and the IP to be assigned. Now imagine you have 100s of servers, so connecting to each one and getting the MAC can be nasty so we can just change the MAC address of these servers as per our need and then just use them to perform PXE boot.

In this tutorial, I will cover what we mean by MAC address, what it’s used for, and how to change it. We will use Kali Linux to demonstrate the steps from this article.

Читайте также:  Linux file user rights

Overview on MAC Address

  • MAC address stands for Media Access Control, and it’s a permanent, physical, and unique address assigned to network interfaces by the device manufacturer.
  • So whether you have a wireless, wired, or Ethernet, each of these network cards comes with a specific address unique to this card. There are no two devices in the world that would have the same MAC address.
  • This address will always be the same to this specific device; even if you unplug it from your computer and connect it to another computer, this network device will always have the same address.
  • Not only that but the MAC address is often used by filters to prevent or allow devices to connect to networks and do specific tasks on the web.
  • Changing your MAC address to another device’s MAC address will allow you to impersonate this device and will enable you to do things that you might not be able to do.
  • So you’d be able to bypass filters or connect to networks that only specific devices with specific MAC addresses can relate to, and you will also be able to hide your identity. Now changing the MAC address is very simple, so let me show you how to do that.

Method-1: Change MAC Address of Network Adapter (Non-Persistent)

Step 1: List Network Interfaces

First, I will use the ifconfig command to list all the network interfaces available on my Kali machine. What I mean by network interface is any device that allows us to connect to a network.

An example is a Wi-Fi card or an Ethernet card, and so on. So you can see first of all we have eth0 , which is a virtual interface created by virtual box when we set Kali to use NAT network.

Solved: Change MAC Address in Linux [Temp & Persistent]

You can see the interface name is eth0, and you can see it has an IP address because, as I said, it’s connected to a network.

If we go here, we can see it saying Wired Connected. The interface represents the wired network that Kali is connected to, which is a virtual NAT network.

You can also see the netmask, the broadcast, and an essential piece of information: the ether, which is the MAC address of this virtual interface.

Now, you can see similar information for my other two interfaces, the lo and the wlan0. The only thing is you can see for both of these interfaces. We do not have an IP address. And the main reason for that is that none of these interfaces is connected to a network.

Now lo is the default interface created by Linux, and wlan0 is my genuine wireless adapter. I can use it to connect to Wi-Fi networks. But if I go on the web in here, you’ll see Wi-Fi is not connected because I didn’t connect to any network, and that’s why it does not have an IP address.

Читайте также:  Linux what is my uid gid

Now, this doesn’t matter because we want to change the MAC address, which is again shown under the ether part, similar to what you see here for eth0 .

Step 2: Disable Interfaces

Now, to change any of the values you see here, you first have to disable the interface. In this example, we want to change the MAC address to represent it by the ether, and the value is right here.

To disable an interface, we’re going to do ifconfig followed by the interface name, wlan0 in my example, followed by down to disable it.

Solved: Change MAC Address in Linux [Temp & Persistent]

Now, if I hit Enter, you’ll see the command runs with no errors, so it means that it got correctly executed. And the next thing that we need to do is change the option that we want to change. And in this example, we want to change the ether, which is the MAC address.

Step 3: Change MAC Address

First, we’re going to type ifconfig , type the interface that we want to change, one of its options, then type the option we want to change. And what we want to change is the hardware address, so we’re going to do hw ether. Then we’re going to give it the lesson that we want to change the MAC address.

For this example, I’m going to use 00:89:76:88:82:33 . Very, very simple command, we’re doing ifconfig wlan0 to select the interface that we want to change its option, we want to set the hardware address, and we want to put this address to this specific address.

So you can use any address that you want, following the same format shown here. Just make sure your address starts with 00 . So I’m going to hit Enter, and again, we don’t see any error messages, so it means the command got appropriately executed.

Solved: Change MAC Address in Linux [Temp & Persistent]

And finally, we need to enable the interface because we disabled it by doing ifconfig wlan0 down , so we need to do ifconfig wlan0 up to allow it. Now the interface is enabled, and if we do ifconfig again, and look at the ether part here, you can see that it is changed to the MAC address that we specified.

Step 4: Verify the new MAC Address

Now, this is done, and your MAC address has changed. Now, you can go ahead and start using the interface, and it’ll appear to have this MAC address instead of its original MAC address. And like I said, this can be useful in so many scenarios.

Solved: Change MAC Address in Linux [Temp & Persistent]

Now, keep in mind, the MAC address will revert to the original one once you restart the computer because we’re only changing the MAC address in memory. We’re not changing the physical MAC address.

Method-2: Change MAC Address of Network Adapter (Persistent)

In this section we will change MAC Address of a network adapter permanently which will be persistent across reboots.

Источник

Оцените статью
Adblock
detector