How can I automatically change my mac address whenever my network device is up or down?

by Hola   Last Updated November 14, 2017 18:02 PM

macchanger automatic script doesn’t work.

I searched here before I asked and all I found was to run macchanger in /etc/rc.local with this simple script:

ifconfig enp2s0 down
macchanger -r enp2s0
ifconfig enp2s0 up

(I just modify eth0 cuz my device name is enp2s0)

Clearly it only setup a random mac address at startup but if I reconnect my network device it get it normal mac address so it isn’t what I’m looking for.

I tried to at least leave a permanent spoofed address but the mac spoof option in the ubuntu default network manager doesn’t do anything, it always sent my real address.

I can’t remember exactly where but I read somewhere that it could be systemd's fault but I'm not really sure how to handle that thing or if really is its fault.

What's the right way to get a random mac address whenever I connect my network device in Ubuntu? I'm running out of ideas.



Related Questions


How to connect to two VPNs at the same time?

Updated July 16, 2015 16:00 PM

Adjust timeperiod for background scanning?

Updated September 22, 2017 16:02 PM

KvmWithBridge: primary network interface (wi-fi)

Updated November 23, 2017 11:02 AM

Open NAT with ICS

Updated June 13, 2015 13:00 PM

how to bring linux bridge up at booting time?

Updated May 09, 2016 08:00 AM