I wanted to randomize my mac address on every boot just like in Windows 10. During my quest for that I tried the following -
According to this post, starting from NetworkManager 1.4.1+ we can do mac address randomization. Mine is 1.10.6 (using Ubuntu 18.04)-

$ dpkg -s network-manager | grep '^Version:'
Version: 1.10.6-2ubuntu1.1

In that post he points to this Gist for configuration details. The gist is virtually identical except that it has an instruction -

# Be sure to change your existing (saved) connections in
# /etc/NetworkManager/system-connections/*

I didn't quite undersand that nor do I know how to do it, so i skipped it and hoped for the best. The gist also had a link to a gnome blog for mac address spoofing in network manager in 1.4.0.

The author metioned to change the file in /usr/lib/NetworkManager/conf.d and NOT in /etc/NetworkManager/conf.d even though he gave an example showing changes in /etc/NetworkManager/conf.d/30-mac-randomization.conf.
Now, in my case the conf.d from /etc contains only one file as follows -

user@user:/etc/NetworkManager/conf.d$ ls

The other one (from /usr) has -

user@user:/usr/lib/NetworkManager/conf.d$ ls
10-dns-resolved.conf              20-connectivity-ubuntu.conf
10-globally-managed-devices.conf  no-mac-addr-change.conf

I edited the file no-mac-addr-change.conf from -


to -


And then I restarted Network Manager -

$ sudo systemctl restart NetworkManager

and also restarted WiFi from GUI, but the mac address is still the same.Checked it by cat /sys/class/net/wlp2s0 address

Has it got something to do with that instruction in the gist that I didn't follow? What am I missing?

Also do the file names matter ? Cause everywhere else I saw a different file name?

  • "but the mac address is still the same." Where? in ip addr show or in iwconfig or elsewhere? – chili555 Dec 8 '18 at 16:53
  • @chili555 From cat /sys/class/net/wlp2s0 address – jar Dec 8 '18 at 16:55
  • @chili555 even ip addr show displays the same thing – jar Dec 8 '18 at 16:57
  • not a direct answer to your question - but I use macchanger to accomplish this. In my chrontab I added the line macchanger -r. That does the job. – Robert Baker Dec 8 '18 at 17:15
  • @Robert Baker it's just that since it's natively possible to do this from Network Manager, I don't want to use macchanger – jar Dec 8 '18 at 17:17

The author metioned to change the file in /usr/lib/NetworkManager/conf.d and NOT in /etc/NetworkManager/conf.d

... if you are a distributor or install the file as part of the installation. User configuration should be in /etc.

I edited the file no-mac-addr-change.conf from -

Here too: as a user, you best don't edit files in /usr. Instead, place the file in /etc/NetworkManager/conf.d, and overwrite the setting. Configuration files are read in a certain order (as documented in man NetworkManager.conf). Files read later amend/overwrite previous settings.

The file /usr/lib/NetworkManager/conf.d/no-mac-addr-change.conf disables changing the MAC address for certain drivers, because the driver doesn't support it. So, unless you have one of these device types, the file had no effect for you to begin with, and adding to the section has no effect either. See the match-device part.

Note that the file disables changing the MAC address for certain drivers because the drivers don't support it. What gives GENERAL.DRIVER in nmcli -f all device show wlp2s0 for you? If you have one of the listed drivers, it may not work even if you configure it in NetworkManager.

In general, look at the logfile of NetworkManager. See the comment in NetworkManager.conf about how to enable debug logging. You should see if NetworkManager fails to set the MAC address of the device (and whether it tries to do so in the first place).

Also, putting wifi.cloned-mac-address= in the [device*] section has no effect. See man NetworkManager.conf. This belongs to a [connection*] instead.

But note the settings under [connection*] only take effect if the corresponding value is not specified in the per-profile setting. For example, if your profile is called "My Wi-Fi", then nmcli connection show "My Wi-Fi" will show you the per-profile wifi.cloned-mac-address that is used. The fallback from the configuration file is only consulted if the per-profile value is unset. So, usually, you would not set the default value in NetworkManager.conf, but instead per-profile with nmcli connection modify "My Wi-Fi" wifi.cloned-mac-address random.


   nmcli connection modify "$PROFILE" wifi.cloned-mac-address random
   nmcli connection up "$PROFILE"

   # verify
   nmcli device
   ip link
|improve this answer|||||
  • The first command gives me the following error - Error: unknown connection ''. – jar Apr 8 '19 at 17:44
  • With "$PROFILE" I meant the name of the connection profile, as you see it in nmcli connection output. Sorry for being unclear. – thaller May 23 '19 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.