Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to change MAC address in Linux

Shulou Source: shulou.com Published: 2022-06-01 10:22:19 09月12日 Update

This article mainly introduces "how to change the MAC address in Linux". In the daily operation, I believe many people have doubts about how to change the MAC address in Linux. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "how to change the MAC address in Linux". Next, please follow the editor to study!

Environment

Centos7.7 Minimal

GNU MAC changer 1.7.0

Query network card and MAC address

[root@localhost ~] # ip link show1: lo:mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 00:0c:29:48:4c:9a brd ff:ff:ff:ff:ff:ff

The name of the network card is ens33,MAC and the address is 00:0c:29:48:4c:9a. Please write down your MAC address and restore it to the original MAC address after the experiment.

Use the macchanger tool to change the MAC address

Macchanger can view and modify MAC addresses.

Install macchanger

[root@localhost ~] # git clone https://github.com/alobbs/macchanger[root@localhost ~] # yum-y install autoconf automake gcc gcc-c++ texinfo

How to use macchanger

Use the following command to generate a random mac address for the ens33 Nic:

[root@localhost] # macchanger-r ens33Current MAC: 00:0c:29:48:4c:9a (VMware, Inc.) Permanent MAC: 00:0c:29:48:4c:9a (VMware, Inc.) New MAC: a2:97:a2:55:53:be (unknown)

Check to see if the MAC address of ens33 has changed

[root@localhost ~] # ip link show ens332: ens33:mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether a2:97:a2:55:53:be brd ff:ff:ff:ff:ff:ff

You can change it to a self-specified mac address, using the following command:

[root@localhost] # macchanger-- mac=XX:XX:XX:XX:XX:XX

If you want to restore to the real MAC address, use the following command:

[root@localhost] # macchanger-p ens33Current MAC: a2:97:a2:55:53:be (unknown) Permanent MAC: 00:0c:29:48:4c:9a (VMware, Inc.) New MAC: 00:0c:29:48:4c:9a (VMware, Inc.)

At this point, the study on "how to change the MAC address in Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Address study command network card face more help practical next name tool article method environment theory knowledge later article website material Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Huawei Apple Shulou Technology Xiaomi