Skip to content

Instantly share code, notes, and snippets.

@sktt
Last active September 4, 2017 01:12
Show Gist options
  • Select an option

  • Save sktt/88bb85ae65661cd242220f73754d0cee to your computer and use it in GitHub Desktop.

Select an option

Save sktt/88bb85ae65661cd242220f73754d0cee to your computer and use it in GitHub Desktop.
Generates a new mac address. You know why it's useful :)
#!/bin/sh
set -e
IF=$1
if [ -z "$IF" ] ; then
echo "Usage: $0 <interface>"
exit 1
fi
ifconfig $IF > /dev/null # stop execution if the interface doesn't exist
MAC=`dd bs=1 count=6 if=/dev/random 2>/dev/null|hexdump -e '/1 "%02X:"' | head -c17`
sudo ifconfig $IF ether $MAC
sudo ifconfig en0 down
sudo ifconfig en0 up
ifconfig $IF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment