Guide to change your MAC address on Linux that really works

If you are paranoid enough you might want to change your MAC address every time you connect to a new Internet access point. After you do a little research with your favorite search engine, and I presume it is not Google and alike, you see a lot of results suggesting you use macchanger or ifconfig utilities. The problem is macchanger confounds NetworkManager’s own MAC changing facility to operate properly. So if you first changed your MAC to a new one with macchanger, NetworkManager would cancel that and use the permanent MAC you intend to hide, like here or here.

Ifconfig is deprecated, and modern Linux distributions are not supplied with it. I presume most of my readers prefer GNU/Linux and *BSD systems as well…

The solution is even simpler than what all those resources tell you to do. You don’t even have to use terminal. NetworkManager can change MAC on its own. If you use mainstream Linux/*BSD distributions, chances are NetworkManager is already installed on your system.

Just right click on your network icon in toolbar -> choose “Edit Connections” with available network you want to use -> type the MAC address in the “Cloned MAC Address” field -> Save Changes. You can also use predefined values for this field.

You can generate random MAC address with this script if you have macchanger installed:

#!/bin/bash

macgenerate () {
  [ -z "$1" ] && echo "Usage: macgenerate vendor-name" && return 1
  Vendor=$(macchanger -l | grep $1 | shuf -n 1 | awk '{print $3}')
  Tail=$(echo $RANDOM | md5sum | sed 's/.\{2\}/&:/g' | cut -c 1-8)
  [ -z "$Vendor" ] && echo "Invalid vendor name" && return 1
  Mac="$Vendor:$Tail"
  echo $Mac
}

I took original script here

That’s all. Reconnect to the network and check your changes, I use Wireshark for this.

P.S.

If you are too paranoid, you could argue about whether the MAC address associated with your network card is changed every time the device scans for Wi-Fi access points nearby. If your Linux distro uses recent version of NetworkManager, you can quietly stop worrying about it because it randomizes MAC address in every 802.11 scan probe. Open the NetworkManager.conf man page and look for scan-rand-mac-address