While playing with macchanger, I noticed that in attempting to create a random mac address, upon bring the wireless connection back online the mac address reverts to the permanent mac address once i reconnect to the internet

the process i went through was

ifconfig wlan1 down

macchanger -r wlan1    (mac address is random)

ifconfig wlan1 up

at this point i am offline (the wifi connection is up but not connected to any specific network). Upon clicking a wireless connection and establishing a connection , the mac address reverts to the permanent one


as an aside, changing the mac address in the wireless network connection gui then resetting the network connection does seem to work; but doing this as originally outlined via macchanger in the terminal still does not

  • Which version of Ubuntu are you running? – Charles Green Nov 30 '17 at 13:33
  • currently using 16.04 – razeal113 Dec 1 '17 at 9:46

I think that the act of bringing up the interface causes it to re-read the mac from hardware. The recommended method of using 'macchanger' is written in https://help.ubuntu.com/community/AnonymizingNetworkMACAddresses, and recommends adding a script to the intereface initialization routines:

Create the file with the command

sudo nano /etc/network/if-pre-up.d/macchanger

into this file, enter the lines


# Radomize the mac address for the given interface
/usr/bin/macchanger -r "$IFACE"

close the file, by pressing Ctrl+o and then Ctrl+x, and mark the file as executable with the command

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

This command will then be executed during the process of bringing the interface up, and assign a random mac at that time.

  • adding these changes didn't seem to resolve the issue for me. Should the line /usr/bin/macchanger -r "$IFACE" be added at the end of the file? – razeal113 Dec 14 '17 at 12:49
  • Yes, that line is the only actual active line in the file. The entire file should be the 4 lines, including the blank line, and the two commented lines. – Charles Green Dec 14 '17 at 14:06
  • This still doesn't seem to work, but also, even if it did randomize the mac address upon bringing the interface up, i have to reset the network in order to reconnect to the internet (the routing tables seem to be gone after bringing down the network and aren't reset upon bringing the interface back up). One thing i have noticed though is that if i go to the internet settings / connections gui and manually set the mac address there then reset the net, the change stays. Where is this file on linux? I could simply make a script to adjust this file field i suppose if macchanger wont work – razeal113 Dec 15 '17 at 10:25

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.