Skip to content

Instantly share code, notes, and snippets.

@carlsednaoui
Created August 29, 2012 02:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlsednaoui/3506354 to your computer and use it in GitHub Desktop.
Save carlsednaoui/3506354 to your computer and use it in GitHub Desktop.
Generate and set a new mac address
# Place this in your .bash_profile to change your mac address
# Simply run newmac from your terminal and boom, you'll have a new mac address
# Change mac address
function newmac() {
local OLDMAC=$(ifconfig en0 | grep ether | cut -d ' ' -f 2)
local GENMAC=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
sudo ifconfig en0 ether $GENMAC
local CURRENTMAC=$(ifconfig en0 | grep ether | cut -d ' ' -f 2)
if [ $GENMAC == $CURRENTMAC ]; then
echo "Old Mac: $OLDMAC";
echo "Current Mac: $CURRENTMAC";
echo 'Great success';
sudo ifconfig en0 down
sleep 3
sudo ifconfig en0 up
else
echo "Old Mac: $OLDMAC"
echo "Current Mac: $CURRENTMAC";
echo 'fak, it didnt work'
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment