Created
August 29, 2012 02:56
-
-
Save carlsednaoui/3506354 to your computer and use it in GitHub Desktop.
Generate and set a new mac address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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