Change (Spoof) a MAC Address in OS X Lion & OS X Mountain 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.
We’ve received a few questions about this recently because the process of changing (sometimes called spoofing) these addresses has changed slightly from version to version in Mac OS X. With that in mind, we will show you how to change a MAC address in the latest versions of OS X 10.7 and 10.8. Launch the Terminal found within /Applications/Utilities/ to get started.
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:xxOS 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, as demonstrated in this video:

The MAC layer address is used by the local network router and switch. It is not used once packets leave the local network so I have no idea why anyone would need to change the MAC layer address.
A lot of networks and routers filter access by MAC address, changing it to an approved address can be necessary.
kinda sounds like a hacking situation…
Not necessarily. IT runs into this all the time when network resources are determined by MAC. Swapping a failed ethernet card changes the address, in some organizations it’s faster to jot down the old number and spoof it rather than waiting x many days to get some other departments approval for the new hardware.
How do you revert to the original MAC address?
run the command again with your default in place, or reboot
same procedure, if you wrote down the original MAC address…
You should not just randomly generate a mac address without knowing how these are assigned. The least significant bit of the first byte MUST be 0 otherwise it will be considered a multicast ethernet and arp to some routers will be ignored.
See http://en.wikipedia.org/wiki/MAC_address, specifically the section on addressing:
If the least significant bit of the most significant address octet is set to 1, the frame will still be sent only once; however, NICs will choose to accept it based on different criteria than a matching MAC address: for example, based on a configurable list of accepted multicast MAC addresses. This is called multicast addressing.
You should take care that the random MAC address you use is “locally administered” and not Multicast:
ruby -e ‘puts (“%02x”%((rand 64)*4|2))+(0..4).inject(“”){|s,x|s+”:%02x”%(rand 256)}’
Hi, I have a problem…when I try to change address with sudo ifconfig en1 Wi-Fi xx:xx:xx:xx:xx:xx it ask me the password but I cannot type anything…anyone can help me?
write the code and don’t care if it is visible. The code and enter
I did to change the MAC in the console, but the change isn’t shooing up in the GUI (Network Preferences Pan) at all -no matter how often I reconnect
Is there anyway to force that?
I changed my mac adr. for eth., but when i restart my computer it returns to the original?Why?
It’s a real change or masking?How can i save it permanently?
Thanks in advance!!!
OK. I work on OS X Lion 10.7.3… I tried the procedure, sure it changes your MAC so it displays in your terminal window. The thing is I cannot connect to any of the wireless networks(!). It doesn’t work. Each time I try to connect almost instantly a comment ‘Connection time-out’ displays. Each time I have to revert to the original MAC address in order to have internet access.
Any help?
Thanks,
DT
I have the same problem… I need to spoof my MAC address to get back into my iTunes match account on the same damn laptop/account I bought it on.. I have 1 month left before it resets, but now that I know I can just change my MAC address I’d definitely do that instead… Any help would be deeply appreciated!
Regarding:
openssl rand -hex 6 | sed ‘s/\(..\)/\1:/g; s/.$//’
Can anyone help modifying the line for creating a random but VALID MAC such that it is always a locally administered (not multicast) one?
openssl rand -hex 1 | tr ‘[:lower:]‘ ‘[:upper:]‘ | xargs echo “obase=2;ibase=16;” | bc | cut -c1-6 | sed ‘s/$/00/’ | xargs echo “obase=16;ibase=2;” | bc | sed “s/$/:$(openssl rand -hex 5 | sed ‘s/\(..\)/\1:/g; s/.$//’ | tr ‘[:lower:]‘ ‘[:upper:]‘)/” | xargs sudo ifconfig en0 ether
This should generate and set a new random valid MAC.
If anyone knows a better way or find any error in code please share.
Great tip, thanks for this!
OSX 10.7.4
I am able to successfully change the MAC address and it does in fact show up on the router, in the DHCP table, and via a network scan done by another device.
However, the GUI still shows the Apple MAC address, though it doesn’t seem to make a difference out on the network.
-Doc
BTW, I don’t use a random MAC address … I want to retain a bit of privacy when on public hotspots, so my Macbook Air is named “Dell User” and my MAC address prefix is one that is registered with Dell.
Same here. Change shows on router but not in Network Pref > Wi-FI > Advanced > Hardware > Mac Address
And the change is only good until a reboot then it reverts back to the original. Would be nice not to have to change on a reboot. I just have to run a small script on startup but still…
OK, I’ve tried this in the past … everything goes as it’s supposed to … but then the Internet connection won’t work … I don’t have wireless … I have a router through the Internet company, like with a wire that connects right into the comp—I’m not sure if that’s a factor. I know the router itself has a separate mac address of its own … I’d like to change that too … but for now I’m willing to settle for just the first problem … Can someone help me w/ this?
I made a simple Preference Pane for this: https://github.com/funkensturm/LinkLiar
Maybe it will help one or the other. I find it kind of convenient.
[...] Change (Spoof) a MAC Address in OS X Lion & OS X Mountain Lion [...]
FYI, system updates seem to undo this little change reverting back to the original MAC address. Doing the procedure again fixes it, no issues.
With the computer serial number I can get the original MAC address? I lost my macbook and I need the mac address.
[...] (the unique ID attached to a physical network interface), but aren’t comfortable with the command line approaches that we’ve discussed before, an excellent free preference panel called LinkLiar makes it [...]
Neither of this works for me. I either get “ioctl (SIOCAIFADDR): permission denied” or “ifconfig: Wi-Fi: bad value” if I use the alternative command from the tips on the bottom.
I have the root user enabled. Please advise?
How did you make it work after that error?
Ok i made it work but it resets on restart.
Is there a way to set random mac address upon each restart?