MAC address spoofing on Linux

Source: Internet
Author: User
Tags linux mint
The NIC manufacturer marks a 48-bit globally unique identifier (GUID, for example, 08: 4f: b5: 05: 56: a0) on each NIC (NIC) when it leaves the factory ), the GUID is the MAC address of the network card. it is used to identify a network card. The 24-bit high MAC address is called OUI (Org

The NIC manufacturer marks a 48-bit globally unique identifier (GUID, for example, 08: 4f: b5: 05: 56: a0) on each NIC (NIC) when it leaves the factory ), the GUID is the MAC address of the network card. it is used to identify a network card. The 24-bit high MAC address is the Unique Identifier of the organization that sets the MAC address for the NIC, the MAC addresses set for different organizations do not conflict. In actual production, not every network device has a different MAC address. sometimes the address space is insufficient. the producer will use the same address space for products sent to different regions and countries .)

Although the MAC address is specified by the vendor, you can change it. this is the legendary "MAC address spoofing ". This article will show you how to play MAC address spoofing on Linux.

Why do you want to play MAC address spoofing?

Why? Here we will give you a few technical reasons. Some network vendors will bind the MAC address on your vro to verify your identity. what if your vro is broken at this time? You can temporarily change the MAC address of your computer to the MAC address of your vro, so that your ISP can re-connect you to the Internet. Is there such a thing ?)

Many DHCP servers rely on MAC addresses to allocate IP addresses. If you want to change the IP address assigned to you, you can change the MAC address. In this way, you don't have to wait for the DHCP server to allocate an IP address again, but you can get a new one immediately.

In addition to technical reasons, there are also some legitimate reasons to explain why you need to change your MAC address: For privacy, for security, you need to hide your real MAC address. Unlike the IP address on the third layer of the ISO model, your MAC address will not change. Before you say I have doubts, please be sure you know what your privacy is. There is an intrusion method called piggybacking. hackers may pretend to be your MAC address in the public WiFi network and pretend to be your identity when you are not present for hacking.

How can I temporarily change the MAC address?

You can change the MAC address when running Linux. Note that when the MAC address is switched, your network will be disconnected. When the computer restarts, the MAC address changes back to the original one. The following describes how to change your MAC address.

Method 1: iproute2

 
 
  1. ___FCKpd___0nbsp;sudo ip link set dev eth0 down 
  2. ___FCKpd___0nbsp;sudo ip link set dev eth0 address 00:00:00:00:00:01 
  3. ___FCKpd___0nbsp;sudo ip link set dev eth0 up  

Method 2: macchanger

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

Install macchanger in Debian, Ubuntu, or Linux Mint:

 
 
  1. ___FCKpd___1nbsp;sudo apt-get install macchanger  

Install macchanger in Fedora:

 
 
  1. ___FCKpd___2nbsp;sudo yum install macchanger  

Install macchanger in CentOS or RHEL:

 
 
  1. ___FCKpd___3nbsp;wget http://ftp.club.cc.cmu.edu/pub/gnu/macchanger/macchanger-1.6.0.tar.gz 
  2. ___FCKpd___3nbsp;tar xvfvz macchanger-1.6.0.tar.gz 
  3. ___FCKpd___3nbsp;cd macchanger-1.6.0  
  4. ___FCKpd___3nbsp;./configure 
  5. ___FCKpd___3nbsp;make 
  6. ___FCKpd___3nbsp;sudo make install  

The following are some examples of advanced use of macchanger. You do not have to manually disable or enable your Nic when using macchanger.

Only change the MAC address:

 
 
  1. ___FCKpd___4nbsp;sudo macchanger --mac=00:00:00:00:00:01 eth0  

When the OUI is consistent, set a random address for MAC:

 
 
  1. ___FCKpd___5nbsp;sudo macchanger -e eth0  

Set a random address for MAC:

 
 
  1. ___FCKpd___6nbsp;sudo macchanger -r eth0  

Obtain the MAC addresses of all NICs and then only list the specified vendors (such as Juniper ):

 
 
  1. ___FCKpd___7nbsp;macchanger -l | grep -i juniper  

Display the original MAC address and disguised MAC address of a network adapter:

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

How can I change the MAC address permanently?

If you want to keep the MAC address disguised after the system restarts, you need to edit the configuration file. For example, if you want to change the MAC address of eth0, do the following:

Under Fedora, CentOS, or RHEL:

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

Alternatively, you can create a boot script in the/etc/NetworkManager/dispatcher. d Directory, provided that you use Network Manager to manage your Network. Assume that you have installed macchanger. the script content is as follows:

 
 
  1. $ sudo vi /etc/NetworkManager/dispatcher.d/000-changemac
  2. #!/bin/bash
  3.  
  4. case "$2" in
  5. up)
  6. macchanger --mac=00:00:00:00:00:01 "$1"
  7. ;;
  8. esac
 
 
  1. $ sudo chmod 755 /etc/NetworkManager/dispatcher.d/000-changemac

In Debian, Ubuntu, or Linux Mint:

Create a new boot script under the/etc/network/if-up.d/directory:

 
 
  1. ___FCKpd___12nbsp;sudo vi /etc/network/if-up.d/changemac  
  2. #!/bin/sh 
  3. if [ "$IFACE" = eth0 ]; then 
  4.   ip link set dev "$IFACE" address 00:00:00:00:00:01 
  5. fi 
 
 
  1. ___FCKpd___13nbsp;sudo chmod 755 /etc/network/if-up.d/changemac  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.