Monday, March 2, 2009

How to change MAC address in Linux(Debian Based Distros)

Media Access Control(MAC) address is a unique identifier assigned to most network adapters or network interface cards (NICs) by the manufacturer for identification.
Although physical MAC address is supposed to be permanent and globally unique identification, it is possible to change the MAC address on most of today's hardware, an action often referred to as MAC spoofing.
The MAC address of a NIC can be changed in Debian Based Linux Distros using following methods;

$ sudo /etc/init.d/networking stop
$ sudo ifconfig <ethernet_interface> hw ether  <new_MAC_address> 
$ sudo /etc/init.d/networking start

The hardware/MAC address assigned this way reverts to its original value after reboot. In order to change the MAC address permanently, add

$ hwaddress ether  <new_MAC_address>

into the appropriate section of /etc/network/interfaces so that the MAC address is set permanently when the network device is started. There is also a tool called macchanger available in linux that changes the MAC address of a NIC.