Linux Script to Enable Randomization of MAC Address on Startup
Made up this little thing for use on Debian\Ubuntu based systems in order to spoof the address for wlan0 to a different address every start up.
So whether you’re trying to preserve anonymity by installing it on a device that you use a lot on public networks, or cover your tracks in the snow when up to mischief by putting it on your Kali install, it is pretty handy.
Worth to note that it’s probably not a wise idea to assign this to an interface that you use static IP addressing for as you’d have to change your MAC in the router settings every start up, in which case it’s better to create a fake MAC address and make it set it to that every start up instead of randomizing by changing:
macchanger -r wlan0 —to–> macchanger –mac=XX:XX:XX:XX:XX:XX wlan0
To enable for other devices besides wlan0 just uncomment out the lines corresponding to your desired NIC in the part of the script as follows:
echo “ #! bin/sh ifconfig wlan0 down #ifconfig wlan1 down #ifconfig eth0 down #ifconfig eth1 down macchanger -r wlan0 #macchanger -r wlan1 #macchanger -r eth0 #macchanger -r eth1 ifconfig wlan0 up #ifconfig wlan1 up #ifconfig eth0 up #ifconfig eth1 up ” > /etc/init.d/macchangerstartup
Instructions:
- Copy script and save as macchanger.sh to your home directory.
- Open up a terminal. Mark file as executable:
sudo chmod +x macchanger.sh - Simply run as root:
sudo bash macchanger.sh
To temporarily disable MAC address to default:
sudo macchanger -p wlan0
To revert permanently:
sudo update-rc.d macchangerstartup
sudo rm /etc/init.d/macchangerstartup