Detailed description of Linux system network card MAC address cloning method

  • 2020-06-07 05:57:14
  • OfStack

How to change the MAC address temporarily?

You can change the MAC address while Linux is running. It is important to note that when the MAC address is converted for 1 hour, your network will be disconnected. When the computer reboots, the MAC address will be changed back to the original address. Here are some ways to change your MAC address.

Method 1: iproute2


$sudo ip link set dev eth0 down
$sudo ip link set dev eth0 address 00:00:00:00:00:01
$sudo ip link set dev eth0 up

Method 2: macchanger

macchanger allows you to change the MAC address to the serial number of different manufacturers.

Install macchanger under Debian, Ubuntu or Linux Mint:


$sudo apt-get install macchanger

Install macchanger under Fedora:


$ sudo yum install macchanger

Install macchanger under CentOS or RHEL:


$ wget http://ftp.club.cc.cmu.edu/pub/gnu/macchanger/macchanger-1.6.0.tar.gz 
$ tar xvfvz macchanger-1.6.0.tar.gz
$ cd macchanger-1.6.0
$ ./configure
$ make
$ sudo make install

Here are some examples of advanced use of macchanger. With macchanger you no longer have to manually disable and enable your network card.

Change MAC address only:


$ sudo macchanger --mac=00:00:00:00:00:01 eth0

Set a random address for MAC when OUI 1 is guaranteed:


$ sudo macchanger -e eth0

Set a completely random address for MAC:


$ sudo macchanger -r eth0

Gets the MAC address of all network CARDS and lists only the specified vendor (Juniper, for example) :


$ macchanger -l | grep -i juniper

Linux: MAC address cloning method shows the original MAC address and the disguised MAC address of a network card:


$ macchanger -s eth0
Current MAC: 56:95:ac:ee:6e:77 (unknown)
Permanent MAC: 00:0c:29:97:68:02 (Vmware, Inc.)

How do I permanently change the MAC address?

If you want to maintain the camouflaged MAC address after a system restart, you need to edit the configuration file. For example, if you want to change the address of eth0 to MAC, do the following:

Under Fedora, CentOS or RHEL:


$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
MACADDR=00:00:00:00:00:0

Or you can build a startup script in/etc/NetworkManager/dispatcher d directory, if you use Network Manager manage your network. Assuming you have macchanger installed, the script reads as follows:


$sudo apt-get install macchanger
0

Under Debian, Ubuntu or Linux Mint:

Create a new boot script and place it in /etc/network/ ES109en-ES110en. d/ directory:


$sudo apt-get install macchanger
1

Related articles: