I'm looking for a way to generate new random mac address for both lan and wifi upon boot.
Has anyone stumbled upon such scripts?
Has anyone stumbled upon such scripts?
I want to automate and mac address change which otherwise have to be done manually in the terminal after every boot
Out of curiosity why do you want to change the MAC address every time you boot ?
because I'm a criminal and it's better to be safe than sorry
p.s.
or I live in a jurisdiction where they have the ISPs identify you by that and the special forces raid your home in the middle of night just because you support the opposition of the currently ruling party. Take your pick![]()
Is that a problem? And if yes, how big is it!?Why you want that? What are you trying ? Sounds like you have to hide something![]()
The IP has nothing to do with the MAC-address.One would think if they're out to get you they would already have your Internet IP number.
The IP has nothing to do with the MAC-address.
# The following command gets a random MAC address:
RNDMAC=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
echo $RNDMAC
# The following command reads the current MAC address:
OLDMAC=`ifconfig en0 | grep ether | awk '{print $2}'`
echo $OLDMAC
# The following command sets a random new MAC address:
sudo ifconfig en0 ether `echo $RNDMAC`
# The following command resets to the original MAC address:
sudo ifconfig en0 ether `echo $OLDMAC`
These same special forces allow you to connect to macrumors to ask how to change MAC addresses ? One would think if they're out to get you they would already have your Internet IP number.
In other words you're late.
Hi,
I think you might be looking for the following commands:
Code:# The following command gets a random MAC address: RNDMAC=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'` echo $RNDMAC # The following command reads the current MAC address: OLDMAC=`ifconfig en0 | grep ether | awk '{print $2}'` echo $OLDMAC # The following command sets a random new MAC address: sudo ifconfig en0 ether `echo $RNDMAC` # The following command resets to the original MAC address: sudo ifconfig en0 ether `echo $OLDMAC`
The "openssl rand" command generates a random hexadecimal number formatted in the MAC address format. You can use this command to set a variable and then use the variable in the "ifconfig en0" command to set the MAC address, as shown. For some reason, in my hands anyway, the MAC address is not always reset and I have to generate a new random MAC address and then it is reset with the new random address. (You will need to use the interfaces appropriate for your machine, whether that is en0 or en1.) When I do this with my wireless, I am disconnected from my wireless AP since my wireless AP is set to only allow connection to certain MAC addresses. I then have to reset my MAC address back to the original (or add the new MAC address to my wireless router) before I can reattach to my wireless router.
Of course, these commands can be included in a script that is executed at boot by launchd or other means. (You will need to remove the last command that resets the MAC address back to the original. And you will need to run this script with root privileges since root privileges are required to change the MAC address and you won't be interactively typing in your password for the "sudo"s.)
Good luck,
Switon
P.S. I recommend that you record your current MAC address before resetting it to a new random one so that you can reset it back to its original value if need be.
Well now that's the super useful post I needed! Thank you mate! You are a ray of light in this thread
Since i'm super new to OS X, can you just say few more words about this launchd thing that should execute the script upon boot?