Skip to content

Instantly share code, notes, and snippets.

@martinsnygg
Last active December 12, 2015 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinsnygg/4708232 to your computer and use it in GitHub Desktop.
Save martinsnygg/4708232 to your computer and use it in GitHub Desktop.
Randomizes MAC id and hostname on OS X 10.8.2
#!/bin/bash
# diassociate from wireless network and flush cache
sudo airport -z
dscacheutil -flushcache
# set random MAC id on en0
sudo ifconfig en0 ether `openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
# set random hostname
sudo scutil --set HostName `openssl rand -hex 3`.local
# write new hostname to netBIOS
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName $HOSTNAME
echo Don´t forget to reconnect wifi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment