Addendum 7/2025:
Implemented at least on a 24.10.2 DSA target:
/etc/config/network
config device
option name 'wan'
option macaddr 'random'
As I wrote here Vodafone changed my IPv4 DHCP lease time to 24h but I don't like that ;- )
Thanks to @anon43134599 I started with this, but it didn't work out because macchanger failed, stating eth0 is up. Couldn't deactivate before execution because then macchanger complains about a missing device.
I changed the script:
#!/bin/sh /etc/rc.common
START=99
start() {
# Generate a random MAC address
new_mac=$(macchanger -e eth0.2 | awk '/New MAC/ {print $3}')
ifconfig eth0.2 down
ifconfig eth0 down
ifconfig eth0 hw ether $new_mac
ifconfig eth0 up
ifconfig eth0.2 up
# Log the changed MAC address
logger -t ChangeWANMAC "WAN MAC address changed to: $new_mac"
}
boot() {
start
}
reload() {
start
Works but:
-
macchanger -r on a brief look always seems to give me the same mac (although I am not sure about that), changed it to macchanger -e
-
macchanger directly wants to change the MAC also if the device is online so I started with eth0.2
What would be nice:
- get the device(s) automatic from interface wan
- rule out MAC address duplicates
- be more elegant ;- )
Some additionally info:
macchanger --help
Usage: macchanger [options] device
-h, --help Print this help
-V, --version Print version and exit
-s, --show Print the MAC address and exit
-e, --ending Don't change the vendor bytes
-a, --another Set random vendor MAC of the same kind
-A Set random vendor MAC of any kind
-p, --permanent Reset to original, permanent hardware MAC
-r, --random Set fully random MAC
-l, --list[=keyword] Print known vendors
-b, --bia Pretend to be a burned-in-address
-m, --mac=XX:XX:XX:XX:XX:XX Set the MAC XX:XX:XX:XX:XX:XX
Report bugs to https://github.com/alobbs/macchanger/issues