Change MAC address in Sabayon/Gentoo Linux
If, for any reason, you want to change your MAC address in Sabayon/Gentoo Linux, there are two easy ways to do it.
Everything is done as root.
The classic one is using ifconfig.
I do an example with wlan0.
Stop interface:
systemctl stop NetworkManager
Change the MAC:
ifconfig wlan0 hw ether XX:XX:XX:XX:XX:XX
where XX:XX:XX:XX:XX:XX is your desired MAC.
Start interface:
systemctl start NetworkManager
Now you will connect using NetworkManager (as usually) with XX:XX:XX:XX:XX:XX as MAC.
Every reboot it’s reset to the original one.
Another useful tool is macchanger:
Usage: macchanger [options] device
-h, --help Print this help
-V, --version Print version and exit
-s, --show Print the MAC address and exit
-e, --endding Don't change the vendor bytes
-a, --another Set random vendor MAC of the same kind
-A Set random vendor MAC of any kind
-r, --random Set fully random MAC
-l, --list[=keyword] Print known vendors
-m, --mac=XX:XX:XX:XX:XX:XX Set the MAC XX:XX:XX:XX:XX:XX
To do the same work as above:
systemctl stop NetworkManager
macchanger --mac=XX:XX:XX:XX:XX:XX wlan0
systemctl start NetworkManager
This can even set a random vendor MAC of the same kind:
systemctl stop NetworkManager
macchanger -a wlan0
systemctl start NetworkManager
You can write a script and put it in /usr/bin.
Take the script below (nmac, Gist) and add your preferences:
read -p "Choose the interface: " iface
echo "Which MAC on $iface do you want?"
echo "1 - Set random vendor MAC of the same kind"
echo "2 - Set number1 MAC"
echo "3 - Set number2 MAC"
echo "0 - User defined MAC"
read -p "Do your choice: " choice
systemctl stop NetworkManager
case $choice in
[0]* ) read -p "Set the MAC XX:XX:XX:XX:XX:XX : " mac
macchanger --mac=$mac $iface;;
[1]* ) macchanger -a $iface;;
[2]* ) macchanger --mac=YY:YY:YY:YY:YY:YY $iface;;
[3]* ) macchanger --mac=YY:YY:YY:YY:YY:YY $iface;;
* ) echo "Please do a valid choice";;
esac
systemctl start NetworkManager
Copy and paste into a new text file, save it with some name (e.g. nmac), make it executable (chmod +x nmac), and copy it into /usr/bin (cp nmac /usr/bin/nmac). Now you can simply use it from the superuser (su) console.
Don’t use it for any illegal purpose, and use it at your own risk.