MacOS – Change MAC address in OS X Yosemite

mac addressmacosNetwork

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.

Best Answer

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