Wednesday, December 22, 2010

how to linux mac spoofing ...

Ubuntu

In Ubuntu, you can explicitly set a MAC address for your network card. You can either do it manually (Working with MAC Addresses) or use a package called macchanger (GNU MAC Changer).
To manually change your MAC address, for example, for eth0, you do the following:
sudo vim /etc/network/interfaces
And then you add following line to end of interface being configured (eth0 in this example):
hwaddress xx:xx:xx:xx:xx:xx
where xx:xx:xx:xx:xx:xx is the MAC address.
So now your interfaces file may look like this:
auto eth0 static
iface eth0 inet static
address 10.10.1.5
netmask 255.255.255.0
gateway 10.10.1.1
broadcast 10.10.1.255
hwaddress ether 02:01:02:03:04:08

Do the following to make sure all changes are applied:
sudo ifdown eth0 (warning: you will lose connectivity on this interface when you run this command, so make sure you are able to access your computer either via console or through another interface to run the rest of the commands)
sudo ifup eth0
sudo /etc/init.d/network restart

CentOS

Open the file of the network interface you want to modify and add the following:
HWADDR=xx:xx:xx:xx:xx:xx
MACADDR=xx:xx:xx:xx:xx:xx
For example, if you want to explicitly specify a MAC address for eth0, you do the following:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
And then you add following line to end of file:
HWADDR=xx:xx:xx:xx:xx:xx
MACADDR=xx:xx:xx:xx:xx:xx
where xx:xx:xx:xx:xx:xx is the MAC address.
So now your ifcfg-eth0 file may look like:
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
DHCP_HOSTNAME=localhost.localdomain
IPADDR=10.10.1.5
NETMASK=255.255.255.0
GATEWAY=10.10.1.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
HWADDR=02:01:02:03:04:08
MACADDR=02:01:02:03:04:08

Do the following to make sure all changes are applied:
sudo ifdown eth0 (warning: you will lose connectivity on this interface when you run this command, so make sure you are able to access your computer either via console or through another interface to run the rest of the commands)
sudo ifup eth0
sudo service network restart