# The other side of the moon

/bb|[^b]{2}/
Never stop Grokking

## Monday, March 28, 2011

Note that these commands work on Linux, FreeBSD and MacOSX (at least versions greater than 10.5).

Before you do anything, make sure the port is up:
sudo ifconfig <iface> up

Where iface is the network interface. This should be something like en0 for the ethernet port on MacOSX, or eth0 for a linux box, etc. If you're not sure, just run the ifconfig command without any arguments... although if you're not sure, you probably shouldn't be doing this anyway ;)

Now, once your interface is up, you can change its MAC address. This only lasts until the next reboot, but given that I almost never shutdown my laptop, it's as good as permanent.

For the ethernet port:
sudo ifconfig en0 ether <new MAC address>

This works even if you're currently connected to a network.

For the wireless card, first disconnect from any wireless networks. I've found that the easiest way to do this is to try to connect to a network that doesn't exist. From your Airport icon in the menu bar, choose "Join Other Network", and type in some random string. Note that you don't need to do this if your airport doesn't automatically connect to a wireless network.

Once you've disconnected, just run the command as above, but for the en1 interface:
sudo ifconfig en1 ether <new MAC address>

You can now reconnect to any wireless network.

Note that even though this is temporary, I do have it set up to be more or less permanent on Ubuntu through my network startup scripts. I'll publish them some other time.