Hi,
I have been working on a script to change mac address of ether1 to a random one. I finished the script and sharing it here for other users who might have similar needs
The script use ether1 packet count as source of randomness and creates a mac address from it. The script also reboots the cable modem (on 192.168.100.1 - default for most residential modems) as cable modem reboot is required to get a new external ip from ISP
:local r
:local tonum do={
:local in ($1->0)
:local j
:for i from=0 to=([:len $in]-1) do={
:local t
:set t [:pick $in $i]
:if ($t!=" ") do={:set $j "$j$t"}
}
:set j ([:tonum $j])
:return $j
}
:local hex 0123456789abcdef
:local mac "";
:set r [/interface ethernet get ether1 rx-bytes]
:set r [$tonum $r]
:local i1 ($r/16)
:set i1 ($i1-($i1/16)*16)
:local i2 ($r-($r/16)*16)
:set r [/interface ethernet get ether1 rx-64]
:set r [$tonum $r]
:local i3 ($r/16)
:set i3 ($i3-($i3/16)*16)
:local i4 ($r-($r/16)*16)
:set r [/interface ethernet get ether1 rx-65-127]
:set r [$tonum $r]
:local i5 ($r/16)
:set i5 ($i5-($i5/16)*16)
:local i6 ($r-($r/16)*16)
:set r [/interface ethernet get ether1 tx-bytes]
:set r [$tonum $r]
:local i7 ($r/16)
:set i7 ($i7-($i7/16)*16)
:local i8 ($r-($r/16)*16)
:set r [/interface ethernet get ether1 tx-64]
:set r [$tonum $r]
:local i9 ($r/16)
:set i9 ($i9-($i9/16)*16)
:local i10 ($r-($r/16)*16)
:set r [/interface ethernet get ether1 tx-65-127]
:set r [$tonum $r]
:local i11 ($r/16)
:set i11 ($i11-($i11/16)*16)
:local i12 ($r-($r/16)*16)
:set mac ([:tostr [:pick $hex $i1]].[:tostr [:pick $hex $i2]].[:tostr [:pick $hex $i3]].[:tostr [:pick $hex $i4]].[:tostr [:pick $hex $i5]].[:tostr [:pick $hex $i6]].[:tostr [:pick $hex $i7]].[:tostr [:pick $hex $i8]].[:tostr [:pick $hex $i9]].[:tostr [:pick $hex $i10]].[:tostr [:pick $hex $i11]].[:tostr [:pick $hex $i12]]);
:log warning "New MAC $mac"
/tool fetch url="http://192.168.100.1/reset.htm?reset_modem=Restart+Cable+Modem" keep-result=no
/interface ethernet set ether1 mac-address=$mac;
I will be happy to see any feedback to make the script better for other users. I have been using it myself for a week (set up a cron job which runs everyday at 4am).