Wednesday, 11 January 2012

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 way 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 desidered 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 random vendor MAC of the same kind:

          systemctl stop NetworkManager
          macchanger -a wlan0 
          systemctl start NetworkManager

You can do a script and put it in "/usr/bin".
Take the script below and add your preferences



Copy and paste in a new text file, save it with some name (p.e. nmac);
make it executable (chmod +x nmac);
copy it in "/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.

No comments:

Post a Comment