script to change mac adress on eth0 and wlan0
Posted: Fri Oct 17, 2014 2:18 pm
This is a handy way to change the mac adress on the ethernet and wireless cards.
you will need macchanger from the debian repo so install it and take a look at the --help
Macchanger can do a lot but right now I only included -r or random chnging, more will come if others like this.
Network manager will change the mac back to the firmware mac so change it before connecting.
this is for a desktop icon to execute the script, I just place it in /usr/local/bin with all my scripts and then copy it to my desktop. One click to execute.
Remember to make both executable and have fun
This is the main script and i called it changemac
you will need macchanger from the debian repo so install it and take a look at the --help
Macchanger can do a lot but right now I only included -r or random chnging, more will come if others like this.
Network manager will change the mac back to the firmware mac so change it before connecting.
this is for a desktop icon to execute the script, I just place it in /usr/local/bin with all my scripts and then copy it to my desktop. One click to execute.
Remember to make both executable and have fun
Code: Select all
[Desktop Entry]
Version=0.0.1
Name=Cange Mac's
Comment=Changes both network cards Mac's
Exec=/usr/local/bin/changemac
Icon=/usr/share/icons/mconfig.png
Terminal=true
Type=Application
Categories=Applications;Utilities;
Code: Select all
#!/bin/bash
# You need to install macchanger from the debian repo to use this
# script to change the mac address of the ethernet and/or wireless cards
# currently as written it will change both at the same time, in the
# near future it will have a menu to choose one or all
# This is to check if your root/superuser and if not prompts you for root's password
if [ $(id -u) != "0" ]; then
/usr/bin/clear
echo
echo -e "You must be root/superuser to run this script $USER\n" >&2
# su -c '' will give a root password prompt for this sesion and then close root when you quit the script
su -c '/usr/local/bin/changemac'
exit 1
fi
# used to change MAC Address on both cards to random mac's
clear
echo -e "Changing Eth0 cat5 mac address\n"
ifconfig eth0 down
macchanger -r eth0
ifconfig eth0 up
echo
echo -e "\n"
echo -e "Changing wlan0 wireless mac address\n"
ifconfig wlan0 down
macchanger -r wlan0
ifconfig wlan0 up
echo -e "\n"
echo -e "eth0 cat5 and wlan0 wireless mac's are changed\n"
sleep 10
exit 0