Home >System Tutorial >LINUX >How to change MAC address in Linux

How to change MAC address in Linux

WBOY
WBOYforward
2024-02-13 12:00:321147browse

Change MAC address

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.

environment

  • Centos 7.7 Minimal
  • GNU MAC changer 1.7.0

Query network card and 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
How to change MAC address in Linux

Record your MAC address, and then restore it to the original MAC address after completing the experiment.

Use the macchanger tool to change the MAC address

macchanger can view and modify the MAC address.

Install macchanger

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

How to use macchanger

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)
How to change MAC address in Linux

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
How to change MAC address in Linux

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.)
How to change MAC address in Linux

Summarize

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!

Statement:
This article is reproduced at:lxlinux.net. If there is any infringement, please contact admin@php.cn delete