How to Spoof A MAC Address on Mac OS X Lion

A MAC address is a unique identification number assigned to network interfaces, these can be attached to physical hardware like NIC and Wi-Fi cards or assigned to virtual machines. On some occasions, you’ll need to change a MAC address to another ID.

Get a New MAC Address
The first thing you’ll want to do is retrieve the intended MAC address. If you have one in mind then use that, but if you aren’t trying to spoof a specific address and just need a random one, use the following command to generate one with openssl:

openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'

MAC addresses are always in the format of xx:xx:xx:xx:xx:xx, yours must conform to this format in order to work. For the purpose of this walkthrough the randomly generated address of “d4:33:a3:ed:f2:12 ” will be used.

Changing the MAC Address

If you aren’t in the Terminal yet, open it now. We’ll use the interface en0 for this, but yours could be en1 (read notes at bottom). The command for changing the MAC address is as follows:

sudo ifconfig en0 ether xx:xx:xx:xx:xx:xx

Replace “xx:xx:xx:xx:xx:xx” with the desired MAC address, in the example case this will look like:

sudo ifconfig en0 ether d4:33:a3:ed:f2:12

Hit return and enter the administrators password to set the new address. To confirm it has been changed, type the following:

ifconfig en0 |grep ether

You can also find it in Network preferences, though the GUI doesn’t always report the MAC change immediately, instead waiting until the network connection has been cycled.

Notes & Troubleshooting

  • If you aren’t sure which interface to use (en0, en1, etc), type “ifconfig” and find it that way. For MacBook Air without an ethernet port the en0 is usually the Wi-Fi interface, whereas a MacBook, iMac, Mac Mini, MacBook Pro, or any Mac that has an ethernet port will probably use en1 for Wi-Fi instead
  • You may want to note the default hardware MAC address before beginning
  • Some Macs will use the following command instead:
    sudo ifconfig en1 Wi-Fi xx:xx:xx:xx:xx:xx

    OS X Lion and later renamed ‘airport’ to Wi-Fi and thus the naming change

  • You will need access to an admin account or have the root user enabled
  • This has been tested on a MacBook Air and MacBook Pro running OS X 10.7 and OS X 10.8, older versions of OS X can go here

The whole process should take no more than 15 seconds or so