Updated for Yosemite 10.10.4
I spend a lot of time at coffee shops, using their wi-fi networks. I’m not sure who is operating these things, or if they’re hacked, so I wanted to add a layer anonymity to my connection. Tons of routers record and store the MAC address of anyone connected. That makes me uneasy. Here’s how I randomized a new (and valid) MAC address on every reboot of my MacBook pro, running OS X 10.10.4 (Yosemite).
Create a Bash script
Open your terminal. Let’s create a folder and an empty script file in one swoop.
sudo mkdir /Scripts && sudo nano /Scripts/mac-random.sh
Nano will open up a new
mac-random.sh file with blank contents. Paste the following in there:
mac-random.sh with the new contents. Now we get need to reference this file on startup!
Load the Bash script on every bootup
But first let’s make sure it has all the right permissions.
sudo chown -R root:admin /Scripts/mac-random.sh sudo chmod u=rwx /Scripts/mac-random.sh
The kosher way OS X loads boot items is with a launchd
.plist file. Let’s create one which references the script.
cd /Library/LaunchDaemons && sudo nano com.superuser.macrandom.plist
Paste the following XML-style contents into the blank file:
Save and exit nano. Then change the permissions on this file that you just saved:
sudo chown -R root:wheel com.superuser.macrandom.plist
Then load the file into launchd:
sudo launchctl load com.superuser.macrandom.plist
Check if you’re good to go…
sudo launchctl list | grep macrandom
If you see the launch item, then this will load on boot!
Once you’ve rebooted, run
ifconfig to check if your MAC address has changed for your wi-fi adapter (named
en1 in my case).