Start your computer with a random mac address
Step 1: Generate a random mac address:
MAC=`echo -n 00; hexdump -n 5 -v -e '/1 ":%02X"' /dev/urandom;`
Step 2 : Bring up the network card with the mac address:
(Here I’m using my wireless card so the interface would be wlan0 but the command works for pretty much any interface).
ifconfig wlan0 down
ifconfig wlan0 hw ether $MAC
ifconfig wlan0 up
That will bring up your network interface with the new mac address.
For those of you that are using Network Manager (nm-applet on your gnome-desktop), you will have to restart the network manager service reconnect to your wireless network.
Ubuntu 9.10 and higher :
service network-manager restart
Ubuntu 9.04 and lower :
/etc/init.d/network-manager restart
Fedora / CentOS :
service NetworkManager restart
Now, to get that setup on boot, add the commands to /etc/rc.local , and you’ll have something like this :
MAC=`echo -n 00; hexdump -n 5 -v -e '/1 ":%02X"' /dev/urandom;` ifconfig wlan0 down ifconfig wlan0 hw ether $MAC ifconfig wlan0 up service network-manager stop service network-manager start
You can modify that script to fit your Linux distribution.
Any tips on how to do this in Windows or OSX?
OSX should be the same, windows I do not know about. The ifconfig command for OSX has a syntax that is just a little bit different.
Windows : http://lantoolbox.com/articles/find-and-change-spoof-your-mac-address-in-windows-xp/
sudo ifconfig en1 ether ‘mac address’
Alternative:
Use “macchanger tool” with “-r” option (set fully random MAC)
sudo macchanger -r wlan0
echo -n 00; hexdump -n 5 -v -e ‘/1 “:%02X”‘ /dev/urandom
You should always set the local bit if you are going to do a random MAC address. It should start with 02.
Actually.. 02 would set the global bit, the local bit would make the mac address start with ’00′. This is how IEEE defines the MAC address, during IPv6 address autoconfiguration that bit is flipped.. so the ’00′ in the hardware MAC becomes ’02′ in the EUI64.
See http://en.wikipedia.org/wiki/MAC_address and check out the picture, http://en.wikipedia.org/wiki/File:MAC-48_Address.svg . In the breakout of the OUI, b2 is the global/local bit. 0 means global OUI enforced and 1 means locally administered.
I have found that DHCP fails after enabling this. I’ve watched the transaction in Wireshark and the Debian system requests an IP and the DHCP server responds but for some reason the Debian system doesn’t see it.