I’d like Linux Mint to randomize my MAC address on startup on all network interfaces (enp2s0f1 & wlp3s0), and notify me if one of them failed to change via a pop-up.

How would I go about doing this?

(I’m running Linux Mint 18.1 64-bit)

  • are you using network manager/wicd/etc or do you connect via /etc/network/interfaces ?
    – ivanivan
    Oct 11 '17 at 22:12
  • @ivanivan I’m connecting via network-manager Oct 11 '17 at 22:52
  • +1 Been thinking myself of doing that, but have not looked how to do it. Oct 12 '17 at 9:30

A more standard way to randomize MAC addresses is using macchanger.

Following (roughly) the instructions of the ubuntu wiki: AnonymizingNetworkMACAddresses


The package macchanger is in the Networking (universe). Install it.

apt-get install macchanger 

Create the Randomizer Trigger

Utilizing Network-Manager's methods to trigger events when a network interface changes state, place the macchanger script into /etc/network/if-pre-up.d.

vi /etc/network/if-pre-up.d/macchanger   

Don't change $IFACE. It is a reference provided by NetworkManager for the particular activated interface.


# Randomize the mac address for the given interface 
/usr/bin/macchanger -e "$IFACE" 

Make it executable.

chmod +x /etc/network/if-pre-up.d/macchanger 

Interface State Change

Now everytime any managed interface is activated, as it passes through the pre-up phase, the network MAC address will be randomized under the VENDOR id.

Fully Random

If you desire a completely random MAC address change the -e in the macchanger script to -r.

  • I have cut steps from the original page, as they are not strictly necessary. Oct 12 '17 at 9:21
  • Thanks for the answer, I’ll try it out and let you know if it worked or not :) Oct 12 '17 at 9:27
  • I've encountered a problem, but don't know where to post it, as the explanation is a bit long. I'll do my best to explain myself. Oct 12 '17 at 21:34
  • I went to create the /etc/network/if-pre-up.d/macchanger file, but it tuns out it already existed, and had content in it (I have no idea why). Here is what it had: Oct 12 '17 at 21:37
  • #!/bin/sh # # randomize MAC address before connecting to wifi or ethernet # # This script should always be run in if-pre-up.d, but unfortunately # NetworkManager does not run if-pre-up.d scripts before it sets up a network # connection (bugzilla.gnome.org/show_bug.cgi?id=387832). # if-post-down.d scripts are run, so there is a symlink to this script # there. That means when running network config from the terminal, macchanger # will be run twice, but it'll only be run in if-post-down.d when using # NetworkManager. (continues) Oct 12 '17 at 21:38

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.