Today, you’ll learn how to make your unique MAC address random which will enhance a bit your privacy. We going to use a old tool for this macchanger with a simple udev rules for this. This solution has the advantage to works for systemd and non-systemd (initd, runnit, etc…)

Dependencies

You only need to install macchanger from your Linux distribution.

Udev rules

Add the following rules to randomize your mac address. arranged from Tails Linux

$EDITOR /etc/udev/rules.d/00-mac-spoof.rules

Add the content bellow:

# Note: ATTR{type}=="1" means ethernet (ARPHDR_ETHER, see Linux'
# sources, beginning of include/linux/if_arp.h)

# Disable MAC spoofing for the following devices
# iPhone tethering ethernet over USB
SUBSYSTEM=="net", ACTION=="add", ATTR{type}=="1", DRIVERS=="ipheth", GOTO="mac_spoof_ignore"
# veth interfaces used by network namespaces
ENV{INTERFACE}=="veth*", ACTION=="add", GOTO="mac_spoof_ignore"

# Perform MAC spoofing otherwise
SUBSYSTEM=="net", ACTION=="add", ATTR{type}=="1", RUN+="/usr/bin/macchanger -e $name"
SUBSYSTEM=="net", ACTION=="add", ATTR{type}=="1", GOTO="mac_spoof_end"

LABEL="mac_spoof_ignore"
SUBSYSTEM=="net", ACTION=="add", ATTR{type}=="1", RUN+="/usr/bin/logger -t spoof-mac -p debug \"MAC spoofing discarded by udev rule for $name ($driver)\""

LABEL="mac_spoof_end"

Verify the path of macchanger here from your system > where macchanger.

Why use macchanger with -e (NIC) instead of fully random?

You should not completely randomise the MAC address. Having a completely random MAC address is obvious and will have the adverse effect of making you stand out.

Madaidans

Special actions on IWD

For those using IWD, you need to edit the config file:

$EDITOR /etc/iwd/main.conf

With the following content:

[General]
UseDefaultInterface=true

Conclusion

In conclusion, setting up MAC address spoofing using macchanger and udev rules is a straightforward process that can enhance your privacy by randomizing your MAC address.

By following the steps outlined, you can ensure that your device blends in more effectively without standing out due to a completely random MAC address. This method is compatible with both systemd and non-systemd systems, making it a versatile solution for various Linux distributions.

Additionally, for users of IWD, specific configuration adjustments are necessary to ensure seamless operation. Overall, this approach provides a practical way to improve your network privacy.