Skip to content

Instantly share code, notes, and snippets.

@vicapow
Created March 24, 2014 18:53
Show Gist options
  • Save vicapow/9746677 to your computer and use it in GitHub Desktop.
Save vicapow/9746677 to your computer and use it in GitHub Desktop.
a small .bash_profile snippet to force renew a new local ip from a DHCP server
random-mac()
{
node -e "var v = [1,2,3,4,5,6,7,8,9,0,'a','b','c','d','e','f']; var r = function(){ return v[Math.floor(Math.random() * v.length)] }; console.log( '00:' + r() + r() + ':' + r() + r() + ':' + r() + r() + ':' + r() + r() + ':' + r() + r())"
}
new-ip()
{
sudo ifconfig en0 ether `random-mac`
sudo ipconfig set en0 BOOTP
sudo ipconfig set en0 DHCP
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment