İçeriğe geç

How to change the MAC address of an Ethernet interface

Change the MAC address of an Ethernet interface temporarily

Check MAC addresses:

$ ifconfig -a | awk '/HWaddr/ {print "Interface: " $1 "\t MAC: " $NF}'
Interface: eth0	 MAC: 08:00:27:2c:a4:69
Interface: eth1	 MAC: 08:00:27:9a:21:24

Shut down desired Ethernet interface (eth0 in this example):

$ sudo ifconfig eth0 down

Specify new MAC address:

$ sudo ifconfig eth0 hw ether 08:00:00:00:00:01

Activate modified Ethernet interface:

# ifconfig eth0 up

Verify changed MAC address:

$ ifconfig -a | awk '/HWaddr/ {print "Interface: " $1 "\t MAC: " $NF}'
Interface: eth0	 MAC: 08:00:00:00:00:01
Interface: eth1	 MAC: 08:00:27:9a:21:24

This change is not permanent as the MAC address on the interface eth0 will revert to the default on next system reboot.

Change the MAC address of an Ethernet interface permanently

To permanently change MAC address of an Ethernet interface you need to edit /etc/network/interfaces configuration file and use hwaddress directive:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# Network interfaces
allow-hotplug eth0
iface eth0 inet dhcp
  hwaddress ether 08:00:00:00:00:01

allow-hotplug eth1
iface eth1 inet dhcp

Reboot or reconfigure network interfaces by hand:

$ sudo service networking restart

MAC Changer

MAC Changer is a utility for viewing/manipulating the MAC address of network interfaces.

Install it using command:

$ sudo apt-get install macchanger

Set random vendor MAC address of the same kind:

$ sudo macchanger -a eth0
Permanent MAC: 84:8f:69:b0:fa:0a (unknown)
Current   MAC: 84:8f:69:b0:fa:0a (unknown)
New       MAC: 00:0e:37:5b:d7:31 (Harms & Wende Gmbh & Co.kg)

Set random vendor MAC address of any kind:

$ sudo macchanger -A eth0
Permanent MAC: 84:8f:69:b0:fa:0a (unknown)
Current   MAC: 00:0e:37:5b:d7:31 (Harms & Wende Gmbh & Co.kg)
New       MAC: 00:24:18:22:02:4b (Nextwave Semiconductor)

Set specific MAC address:

$ sudo macchanger -m 02:02:02:00:00:01 eth0
Permanent MAC: 84:8f:69:b0:fa:0a (unknown)
Current   MAC: 00:24:18:22:02:4b (Nextwave Semiconductor)
New       MAC: 02:02:02:00:00:01 (unknown)

Set fully random MAC:

$ sudo macchanger -r eth0
Permanent MAC: 84:8f:69:b0:fa:0a (unknown)
Current   MAC: 02:02:02:00:00:01 (unknown)
New       MAC: f6:61:c0:6a:14:66 (unknown)

Set another MAC address of the same vendor:

$ sudo macchanger -e eth0
Permanent MAC: 84:8f:69:b0:fa:0a (unknown)
Current   MAC: f6:61:c0:6a:14:66 (unknown)
New       MAC: f6:61:c0:53:a0:5f (unknown

Revert to the default MAC address:

$ sudo macchanger -p eth0
Permanent MAC: 84:8f:69:b0:fa:0a (unknown)
Current   MAC: f6:61:c0:53:a0:5f (unknown)
New       MAC: 84:8f:69:b0:fa:0a (unknown)

Display a vendor MAC address list to choose from

$ macchanger -l
Misc MACs:
Num    MAC        Vendor
---    ---        ------
0000 - 00:00:00 - Xerox Corporation
0001 - 00:00:01 - Xerox Corporation
0002 - 00:00:02 - Xerox Corporation
0003 - 00:00:03 - Xerox Corporation
0004 - 00:00:04 - Xerox Corporation
0005 - 00:00:05 - Xerox Corporation
0006 - 00:00:06 - Xerox Corporation
0007 - 00:00:07 - Xerox Corporation
0008 - 00:00:08 - Xerox Corporation
0009 - 00:00:09 - Xerox Corporation
0010 - 00:00:0a - Omron Tateisi Electronics Co.
0011 - 00:00:0b - Matrix Corporation
0012 - 00:00:0c - Cisco Systems, Inc.
0013 - 00:00:0d - Fibronics Ltd.
0014 - 00:00:0e - Fujitsu Limited
0015 - 00:00:0f - Next, Inc.
0016 - 00:00:10 - Sytek Inc.
[...]

Common problems

$ ifconfig eth0 hw ether 02:00:01:00:00:02
SIOCSIFHWADDR: Operation not permitted

You need root permissions to alter network interface.

$ sudo ifconfig eth0 hw ether 02:00:00:10:10:10
SIOCSIFHWADDR: Device or resource busy - you may need to down the interface

Shut down the network interface first.

$ sudo ifconfig eth0 hw ether 01:00:00:10:10:10
SIOCSIFHWADDR: Cannot assign requested address

This is not an unicast address as the first octet needs to be even. Look at the image below to understand it better. This image is from Wikipedia – MAC address page and licensed under the Creative Commons Attribution-Share Alike 2.5 Generic, 2.0 Generic and 1.0 Generic license.

MAC-48_Address

by Milosz Galazka on January 11, 2013 and tagged with Debian, Networking, Command-line, Enhanced security

It is very easy to change the MAC address of an Ethernet interface and make this change permanent. I will briefly explain how to do this using standard commands and one particularly useful tool MAC Changer.

Kategori:LinuxNetwork

İlk Yorumu Siz Yapın

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir