Created
May 15, 2017 09:02
-
-
Save trotzig/7783e7fc6b5f03b7386d94edc91647c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| if [ ! -f .ORIGINAL_MAC_ADDRESS ]; then | |
| ifconfig en0 | grep ether | cut -d' ' -f2 > .ORIGINAL_MAC_ADDRESS | |
| echo "Backup of original MAC address saved in .ORIGINAL_MAC_ADDRESS" | |
| fi | |
| if [[ -z "$1" ]]; then | |
| echo "Usage: ./new-mac-address.sh [generate|reset]" | |
| exit 0 | |
| fi | |
| if [[ "$1" = "generate" ]]; then | |
| MAC=da:`openssl rand -hex 5 | sed 's/\(..\)/\1:/g; s/.$//'` | |
| elif [[ "$1" = "reset" ]]; then | |
| MAC=`cat .ORIGINAL_MAC_ADDRESS` | |
| else | |
| echo "Unknown command: $1" | |
| exit 0 | |
| fi | |
| echo "Changing the MAC to $MAC. You may be asked for a root password." | |
| sudo ifconfig en0 ether $MAC |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use this script:
To generate a new mac address, run
This will save a
.ORIGINAL_MAC_ADDRESSfile in the current directory. Then, to restore your old mac address, runRestoring the original mac address isn't strictly needed, but can be helpful if you have external devices (e.g. other wifi routers) that have your mac address stored.