4 ms·
Cool script--it has some useful features like generating a random MAC. But it's also possible to set your mac with: sudo ifconfig [device] [mac] ...and one ca
by leoh 14y ago
Cool script--it has some useful features like generating a random MAC. But it's also possible to set your mac with:
sudo ifconfig [device] [mac]
...and one can replace [mac] with `openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'` for a random address.
- TkTech 14y agoThat doesn't always work without a few extras, as explained on the page.
- nikcub 14y agoshould redirect the error/warning output so that it isn't mashed into the command: openssl rand -hex 6 2>/dev/null | sed 's/\(..\)/\1:/g; s/.$//' because if you are running this on startup there is a chance HOME or RANDFILE aren't set yet, the .rnd file doesn't exist or the permissions on it are not set properly - resulting in a warning such as "PRNG not seeded" or "unable to write 'random state'" that would be passed into the ifconfig command.
- decklin 14y agoCommand substitution does not capture standard error.
- nikcub 14y agoyou're right, it is from my own script where I do it different with more sanity checks and my own errors, I just applied it to the line above. I'm also in that habit for anything fired at startup or in cron so you don't pollute logs.
- tedunangst 14y agoYou probably want to mask off the multicast bits.
- FootballMuse 14y agoJust leave out the [mac] and it will give you a random address. i.e. sudo python SpoofMAC.py en1