Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change the MAC address in Linux

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to change the MAC address in Linux, the article is very detailed, has a certain reference value, interested friends must read it!

Change the MAC address in Linux

Let's take it step by step:

Find your MAC address and network interface

Let's find out some details about the network card in Linux. Use this command to get network interface details:

Ip link show

In the output, you will see some details and the MAC address:

1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:002: eno1: mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 link/ether 94:c6:f8:a7:d7:30 brd ff:ff:ff:ff:ff:ff3: enp0s31f6: mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000 link/ether 38:42:f8:8b:a7:68 Brd ff:ff:ff:ff:ff:ff4: docker0: mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default link/ether 42:02:07:8f:a7:38 brd ff:ff:ff:ff:ff:ff

As you can see, here, my network interface is called enp0s31f6,MAC and the address is 38:42:f8:8b:a7:68.

You may need to write it down in a safe place so that you can restore it to the original MAC address later.

Now you can continue to change the MAC address.

Be careful!

If you do this on the currently used network interface, your network connection may be interrupted. Therefore, try this method on another network card, or prepare to restart the network.

Method 1: use Macchanger to change the MAC address

Macchanger is a simple program to view, modify and manipulate the MAC address of a network card. It is available in almost all GNU/Linux operating systems, and you can install it using the distribution's package installer.

On Arch Linux or Manjaro:

Sudo pacman-S macchanger

On Fedora, CentOS, and RHEL:

Sudo dnf install macchanger

On Debian, Ubuntu, Linux Mint, Kali Linux:

Sudo apt install macchanger

important! You will be asked to choose whether macchanger should be set to run automatically each time the network device is turned on or off. Every time you connect a network cable or restart WiFi, it will provide a new MAC address.

Not a good idea to run it automatically

I don't recommend running it automatically unless you do need to change your MAC address every time. Therefore, select "No" (press Tab) and press enter to continue.

How to use Macchanger to change MAC address

Do you remember the name of the network interface? You got it in the previous step.

Now, to assign a random MAC address to the network card, use:

Sudo macchanger-r enp0s31f6

After changing the MAC, use the following command to verify:

Ip addr

Now you will see that the MAC has been forged.

To change the MAC address to a specific value, specify a custom MAC address using the following command:

Macchanger-mac=XX:XX:XX:XX:XX:XX

Where XX:XX:XX:XX:XX:XX is the new MAC you want to change.

Finally, to restore the MAC address to its original hardware value, run the following command:

Macchanger-p enp0s31f6

But you don't have to. When the system is rebooted, the changes are automatically lost and the actual MAC address is restored again.

You can check the manual page at any time for more details.

Method 2: use iproute2 to change the Mac address (intermediate knowledge)

I suggest you use macchanger, but if you don't want to use it, you can use another way to change the MAC address in Linux.

First, turn off the network card using the following command:

Sudo ip link set dev enp0s31f6 down

Next, set up the new MAC using the following command:

Sudo ip link set dev enp0s31f6 address XX:XX:XX:XX:XX:XX

Finally, reopen the network using the following command:

Sudo ip link set dev enp0s31f6 up

Now, verify the new MAC address:

Ip link show enp0s31f6 above is all the contents of the article "how to change the MAC address in Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report