#!/bin/sh /etc/rc.common
START=99
start() {
# Generate a random MAC address
new_mac=$(macchanger -r eth0 | awk '/New MAC/ {print $3}')
# Set the new MAC address for the WAN interface
ifconfig eth0 down
ifconfig eth0 hw ether $new_mac
ifconfig eth0 up
# Log the changed MAC address
logger -t ChangeWANMAC "WAN MAC address changed to: $new_mac"
}
boot() {
start
}
reload() {
start
}
But it is not the case. I needt o change MAC on BSSID (like for devices connect to router). I need exactly on ALL interfaces…
And it will be better if it will be done without external package.
generate_random_mac() {
local parts=()
for _ in {1..6}; do
parts+=("$(printf '%02X' $((RANDOM % 256)))")
done
echo "${parts[*]//\ /:}"
}
Thing above generated by Claude AI - maybe it will work?
#!/bin/sh /etc/rc.common
START=99
start() {
# Get a list of all network interfaces
interfaces=$(ip link | awk -F: '$0 !~ "lo|vir|wl|^[^0-9]"{print $2;getline}')
# Loop through each interface
for interface in $interfaces; do
# Generate a random MAC address
new_mac=$(macchanger -r $interface | awk '/New MAC/ {print $3}')
# Set the new MAC address for the current interface
ifconfig $interface down
ifconfig $interface hw ether $new_mac
ifconfig $interface up
# Log the changed MAC address
logger -t ChangeMAC "MAC address changed to: $new_mac on interface: $interface"
done
}
boot() {
start
}
reload() {
start
}