Skip to content

Instantly share code, notes, and snippets.

@huglester
Created June 26, 2016 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huglester/4e2c654ab4055a52fd7b0c6c1b5523a3 to your computer and use it in GitHub Desktop.
Save huglester/4e2c654ab4055a52fd7b0c6c1b5523a3 to your computer and use it in GitHub Desktop.
MAC address changer for MacOSX
#!/bin/bash
ORIGINAL_MAC="00:11:22:33:44:55"
RANDOM_MAC=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
INTERFACE=en0
MAC=$RANDOM_MAC
if [ "$1" = "original" ]; then
MAC=$ORIGINAL_MAC
fi
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -z
sudo ifconfig $INTERFACE ether $MAC
sudo networksetup -detectnewhardware
sudo ifconfig $INTERFACE down
sudo ifconfig $INTERFACE up
echo "MAC address is now: $MAC"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment