I usually changed my MAC address with the following commands:

# Get a New MAC Address
openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'
# Changing the MAC Address
sudo ifconfig en0 ether d4:33:a3:ed:f2:12

When I enter:

ifconfig en0 |grep ether

I still get the old MAC address :( - Who can help? I would love to have a script or system to automatically change it on system boot.

  • 3
    Have you tried SpoofMAC (pip install SpoofMAC)? This still works on Yosemite for me. – L3viathan Oct 21 '14 at 12:27

One possible problem is that randomly generated MACs will fail half the time. The first byte of a MAC address needs to be even (e.g. end in 0, 2, 4, 6, 8, A, C, E).

So, for example, 3b:92:22:cf:55:7e wouldn't work because '3b' is odd. See Wikipedia's MAC address article for the details (even = unicast, odd = multicast).

To avoid this problem, you can slightly edit your random-MAC sed command to force the second nibble to 0.

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

Combining this with hrbrmstr's answer worked for me:

sudo /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --disassociate
sudo ifconfig en0 ether $(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/./0/2; s/.$//')
networksetup -detectnewhardware
  • 2
    This method worked for me. This needs to go higher on the answer list. – Feng Huo Dec 24 '15 at 19:33
  • One thing to make that a wee bit shorter: sudo /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -z; sudo ifconfig en0 ether a0$(openssl rand -hex 5 | sed 's/\(..\)/:\1/g'); networksetup -detectnewhardware It does make it a little less random. – Kevin Lyda Aug 29 '17 at 6:21

You need to disassociate the device before changing the MAC address. For en0, it will be:

sudo /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -z
sudo ifconfig en0 ether d4:33:a3:ed:f2:12
networksetup -detectnewhardware
  • I tried this, and it still didn't work for me. – Feng Huo Dec 24 '15 at 19:30
  • @FengHuo it worked for me, on 10.11.2 (though I used a different MAC address) – Mint Jan 17 '16 at 18:15
  • Works on 10.11.6 – Paweł Szczur Oct 18 '16 at 13:51
  • 2
    You just made our family vacation much more enjoyable for the parents. Had to get the Apple TV onto the hotel's network behind a login screen and spoofing the MAC address worked a charm :) – stevenhaddox Oct 30 '16 at 4:44

Ferros made a sweet node tool to do just this https://github.com/feross/spoof

He has a Python version as well https://github.com/feross/SpoofMAC

  • 5
    Installing node.js to do something which can be done by simply running ifconfig seems kind of overkill... – nohillside Sep 6 '15 at 6:20
  • 1
    Kind of goes without saying that it's a solution for node users. He also has a Python (which comes pre-installed on Macs) version github.com/feross/SpoofMAC – Tyler Buchea Sep 6 '15 at 6:27

This command works fine for me, the random script have I taken from this answer: https://serverfault.com/a/299564 from MadHatter.

sudo ifconfig en0 ether $(perl -e 'for ($i=0;$i<5;$i++){@m[$i]=int(rand(256));} printf "02:%X:%X:%X:%X:%X\n",@m;') && sudo ifconfig en0 down && sudo ifconfig en0 up

Use this

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

See the manual page of ifconfig

man ifconfig

Here's my contribution to change your MAC address: https://gist.github.com/vinyll/b511159cce2d25edafe78403749088ca

#/bin/sh

# Instructions:
# 1. Copy this script locally and run the following `chmod +x mac-address-spoofer.sh`
# 2. Later, run the following: `./mac-address.spoofer.sh` and see your MAC address changing.

echo "origin MAC address: " `sudo ifconfig en0 ether | grep ether`
sudo ifconfig en0 ether `openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
echo "new MAC address: " `sudo ifconfig en0 ether | grep ether`

This works!

Steps:

  1. Get the MAC address of your Apple TV and write it down. It's found in the Network Settings.

  2. Get the MAC address of your MacBook (Yosemite OS version). Type "ifconfig" in a terminal window. It will be in the "En0" section.

  3. Cut/Paste the following (replacing the X's with your Apple TV MAC address) into a teminal window:

change MAC OSX to the Apple TV MAC

sudo /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -z

sudo ifconfig en0 ether XX:XX:XX:XX:XX:XX

networksetup -detectnewhardware

  1. Enter your password if prompted and repeat step 3, if necessary**

  2. Reconnect to the hotel wireless with your MAC (not Apple TV) and accept the conditions of service.

  3. Cut/paste the following into the terminal window (replace the Y's with your MAC OSX MAC address)

change MAC address back to original

sudo /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -z

sudo ifconfig en0 ether YY:YY:YY:YY:YY:YY

networksetup -detectnewhardware

  1. Connect to the hotel wireless with your Apple TV.
  • 1
    How does this relate to the problem described in the question? – nohillside Sep 20 '15 at 5:05
sudo ifconfig en0 ether `openssl rand -hex 5|perl -nE '$s.=join":",/../g}{say"02:$s"'`&& sudo ifconfig en0 down && sudo ifconfig en0 up

My is much smarter :)

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • What makes your answer smarter? What does smarter mean in this context? – Michael Ozeryansky Mar 15 at 14:54

protected by Community Mar 7 at 16:43

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.