Thursday, November 24, 2011

How to Change MAC Address on RHEL/CentOS/Fedora

On the RHEL/CentOS/Fedora boxes, there is a line named HWADDR in the interface configuration file /etc/sysconfig/network-scripts/ifcfg-eth0, for example, storing the MAC address of the corresponding ethernet interface.

Nothing will happen if you change the MAC addresss in this line, and you will probably receive the following notice when restart the network service.

Shutting down interface eth0:  Device eth0 has MAC address AA:BB:CC:DD:EE:FF, instead of configured address 00:11:22:33:44:55. Ignoring.

To change the MAC address, just keep the HWADDR as it is, and add the following line to the above file.

MACADDR=00:11:22:33:44:55

Restart the network service.

# service network restart
# ifconfig eth0

New MAC address! Congrats!!!

Note: You should change eth0 to eth1, or the Ethernet interface you want to change its MAC address.