Generate 12 times a random number
viewtopic.php?f=9&t=175453&p=858629#p858629
each time you do % 16 you can have random results from 0 to 15, pick from one arraythe corresponding digit.
Make sure that the 1st bit (bit 0) on 2nd digit is always 0, or the network do not work as expected....
and if is generated MAC must have 2nd bit (bit 1) on 2nd digit always 1.
:global randomnum do={
/system resource irq
:local tmpsum 0
:foreach i in=[find] do={:set tmpsum ($tmpsum + [get $i count])}
:set tmpsum [:tostr $tmpsum]
:local lentmp [:len $tmpsum]
:return [:tonum [:pick $tmpsum ($lentmp - 2) $lentmp]]
}
{
:local arrhex [:toarray "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F"]
:local rndmac ; :local tmp
:for x from=1 to=12 step=1 do={
:set tmp ([$randomnum] % 16)
# this makes it always a valid MAC
:if ($x = 2) do={:set tmp (($tmp | 0x2) & 0xE)}
:set rndmac "$rndmac$($arrhex->$tmp)"
:if ([:tostr [:len $rndmac]] ~ "(2|5|8|11|14)") do={:set rndmac "$rndmac:"}
}
:put $rndmac
}