Log in

Registration

Change MAC Addresses of Network Interfaces

Posted: August 23, 2011 / in: Nuts and Bolts / No comments

network-card-shaddowThere are rare situations where the modification of MAC addresses are extremely useful, e.g. when performing network based development or networks administration.

This article illustrates how to modify MAC addresses of hard wired ethernet interfaces and wireless LAN interfaces when utilizing IP networks.

Basics

Every network interface has a unique hardware address preconfigured. This address is availabe to the local operation system and remote systems communicating with/via your local network interface. The predefined hardware address is called MAC address.

There are a number of scenarios where you are required to modify your local MAC address.

Please note that modifying MAC addresses is not supported by every network interface and not all bit permutations are allowed to be set.

Before changing the MAC address of network interfaces make sure that you feel certain what you are doing and what (legal) consequences are involved with this step – especially in corporate networks!

Modify MAC Addresses

The following three simple steps are required to perform the reconfiguration.

  • bring down the desired network interface
  • set the new MAC address
  • reactivate the network interface

If you did choose a valid MAC address and your device supports the reconfiguration of MAC addresses then you are done. There is nothing else to do!

The following sections describe what commands are required to perform the reconfiguration by utilizing some real world examples.

Ethernet Devices

The following command line session illustrates how to reconfigure your local ethernet device.

# print a list of running network devices
$ ifconfig
eth0      Link encap:Ethernet  HWaddr e0:cb:33:44:aa:bb  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:46 
[...]
 
# now we did decide to reconfigure eth0, so
# bring down the interface eth0
$ sudo ifconfig eth0 down
 
# set the new MAC address
$ sudo ifconfig eth0 hw ether 02:01:02:03:ee:ff
 
# restart the interface
$ sudo ifconfig eth0 up
 
# show list of devices
$ ifconfig
eth0      Link encap:Ethernet  HWaddr 02:01:02:03:ee:ff  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:46 
[...]
 

 

WLAN Devices

The reconfiguration of wireless LAN devices works the same way as described before! Take a look at the following command line session, where the device wlan0 is going to be reconfigured.

# print a list of running network devices
$ ifconfig
[...]
wlan0     Link encap:Ethernet  HWaddr 00:25:d3:ff:33:77  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:27000 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20556 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27410368 (27.4 MB)  TX bytes:3017865 (3.0 MB)
[...]
 
# now we did decide to reconfigure wlan0, so
# bring down the interface wlan0
$ sudo ifconfig wlan0 down
 
# set the new MAC address
$ sudo ifconfig wlan0 hw ether 00:22:02:03:04:08
 
# restart the interface
$ sudo ifconfig wlan0 up
 
# show list of devices
$ ifconfig
[...]
wlan0     Link encap:Ethernet  HWaddr 00:22:02:03:04:08  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:27000 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20556 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27410368 (27.4 MB)  TX bytes:3017865 (3.0 MB)
[...]
 

Incoming search terms:

© Copyrights and Licenses, 2012 - Linux-Support.com The Professional Linux and OSS Services Portal