Saturday, August 30, 2008

Change the MAC address of a NIC in Debian system


Today we will see how to change the MAC address of a Network Interface Card (NIC) in a Debian/Debian like system.

There are a lot of reasons you might want to manually set your MAC address for your network card.

To do so, we need to edit the "/etc/network/interfaces" file.
Run this command in a shell:
gedit /etc/network/interfaces
vim /etc/network/interfaces

We should see the line for the NIC, it should be eth0 for the first Ethernet interface, or wlan0 for the first wireless Lan. If we have dhcp enabled, it will look like this:

auto eth0
iface eth0 inet dhcp

By adding another line we shall change the NIC MAC address:

auto eth0
iface eth0 inet dhcp
hwaddress ether 00:13:e8:a5:2a:c9

MAC address (Media Access Control), is a 6 bytes address in hexa format, its format should look like this: xx:xx:xx:xx:xx:xx. Each x is a number from 0-9, or a letter from a-f.

Now, we have to restart the networking service for the changes to take effect, by running this command in a shell as root:
/etc/init.d/networking restart

After changes take effect, we have successfully changed the MAC address of our happy NIC.


No comments: