Last active
January 25, 2017 13:33
-
-
Save Lifelovinglight/cfdebf2ac49a9a9d3150d4bb8a3a38cd to your computer and use it in GitHub Desktop.
Tiniest mac changer, keeps your manufacturer hardware prefix.
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
#!/bin/bash | |
if [ "$#" -lt 1 ]; then | |
echo "Usage: $0 <interface label>" | |
else | |
NEW_MAC=$(ip link show $1 | tail -n1 | grep -Po 'link/ether \K[[:xdigit:]:]{8,8}') | |
for i in {0..2}; do | |
printf -v BYTE "%02x" $(($RANDOM%256)) | |
NEW_MAC=$NEW_MAC:$BYTE | |
done | |
ip link set dev $1 address $NEW_MAC | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment