Home >System Tutorial >LINUX >How to change MAC address in Linux
Sometimes, we may not want our real MAC address (physical address) to be exposed on the public network. Alternatively, the network administrator may block a specific MAC address. This article will introduce how to use the macchanger tool to change the MAC address.
Use the following command to query the network card and MAC address:
sql复制代码[root@localhost ~]# ip link show 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:00 2: ens33: mtu 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
Record your MAC address, and then restore it to the original MAC address after completing the experiment.
macchanger can view and modify the MAC address.
Use the following command to install macchanger:
graphql复制代码[root@localhost ~]# git clone https://github.com/alobbs/macchanger [root@localhost ~]# yum -y install autoconf automake gcc gcc-c++ texinfo
The following command will generate a random MAC address and apply it to the ens33 network card:
r复制代码[root@localhost ~]# macchanger -r ens33 Current 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)
Use the following command to check whether the MAC address of ens33 has changed:
sql复制代码[root@localhost ~]# ip link show ens33 2: 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
To change to the specified MAC address, please use the following command:
csharp复制代码 [root@localhost ~]# macchanger --mac=XX:XX:XX:XX:XX:XX
If you want to restore to the real MAC address, please use the following command:
r复制代码[root@localhost ~]# macchanger -p ens33 Current 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.)
This article explains why you want to change your MAC address and how to use the macchanger tool to do it.
The above is the detailed content of How to change MAC address in Linux. For more information, please follow other related articles on the PHP Chinese website!