Create random-mac.sh script:
echo "#!/bin/sh
MAC=\$(m=\$(openssl rand -hex 5) && echo \"00\":\${m:0:2}:\${m:2:2}:\${m:4:2}:\${m:6:2}:\${m:8:2})
logger \"Changing MAC address to \$MAC\"
nvram set wan0_hwaddr_x=\"\$MAC\"
nvram commit
service \"restart_wan_if 0\"" > /jffs/scripts/random-mac.sh
Append to /jffs/scripts/services-start:
echo "cru a random-mac \"0 5 * * * /jffs/scripts/random-mac.sh\" # Randomize MAC address" >> /jffs/scripts/services-start
Make sure you set executable permission using the chmod command:
chmod a+rx /jffs/scripts/services-start
chmod a+rx /jffs/scripts/random-mac.sh
Enable boot time support for /jffs/scripts/ Support for these scripts stored under /jffs/scripts/ must be enabled, under Administration -> System on the webui:
- Format JFFS partition at next boot = No
- Enable JFFS custom scripts = Yes
Make it effective now:
cru a random-mac "0 5 * * * /jffs/scripts/random-mac.sh" # Randomize MAC address
To list current jobs run:
cru l
To delete current jobs run:
cru d random-mac
Verify it:
cru l
Reference: https://www.cyberciti.biz/faq/how-to-add-cron-job-on-asuswrt-merlin-wifi-router/
for me working: replace "service "restart_wan_if 0" and add
killall -USR1 udhcpc
sleep 10
service "restart_wan"