Wednesday, August 29, 2007

Changing MAC Address

In a network where IP Address is provided by DHCP mode, how will you identify a particular computer? The answer to this is MAC (Media Access Control) Address of an ethernet card. Every ethernet card is burnt with a MAC address. But, the MAC address can be changed. Here is how to:

ifconfig ethx down
where ethx is the interface. This command is to deactivate the ethernet card.

ifconfig ethx hw ether xx:xx:xx:xx:xx:xx
where xx:xx:xx:xx:xx:xx is the 12 digit hex address which you want the address of your ethernet card to be.

ifconfig ethx up
This command is to activate the ethernet card.

And you are there.

There are softwares like macchanger which can also be used to change the MAC address. They do not do anything different from the previous method expect allowing you change to MAC address from particular vendor. So, the above method is advisible rather than using macchanger.

But your MAC address gets restored once you restart your computer. Now how to this permanently. Well, there are different methods for this. You can write a script and add to your run-level to load it when computer boots. But I prefer a more easy and convenient method of editing the file /etc/network/interfaces.
In the above file, you will see line like
auto ethx
Below this line add the following line:
hwaddress ether xx:xx:xx:xx:xx:xx

N.B. : You will need root permissions to do the above tasks.

The above examples are given with reference to Kubuntu-7.04. The methods described above should work with others Linux distros as well.

6 comments:

unknown said...

This is nice idea specially for internet .This idea may be harmful for isp so i think we should stop such illegle thing .

Jitendra Harlalka said...

Changing MAC Address is really a handy tool for handling DHCP based networks with large number of computers since, it can allow you to set the MAC Address as desired by you and hence eliminate the need to remember them all or maintaining a database.
unknown
Why do you think this may be harmful to ISP? And, it is definitely not illegal. There are ways in which ISPs can enhance their security.

vivu said...

thanks for the post.

Harshad Joshi said...

Thats ok we can change the MAC addres temperorily, but I think L2 Switch working at Datalink layer knows what the original MAC address is..

Can someone provide more details in this case??

Jitendra Harlalka said...

Hi Harshad,
Thanks for your comment.

And you are right, Datalink layer knows about the original MAC address etched in the chip. It is the OS which overrides the original.

So, if you change the MAC address in one of the OS on your multiboot PC, the other OS uses the original MAC address of your NIC.

Silvester Norman said...

That means that MAC Address is the one and only parameter to secure internet connection.

Thanks
Silvester Norman

Change Mac Address