To avoid unwanted MAC address changes, Locally Administered Addresses (https://en.wikipedia.org/wiki/MAC_addre ... ed_address) can be used.
Here's a script to automatically set the MAC of all configured bridges based on the hardware MAC address of ether1:
Code: Select all
:local locAdmMac
:local originalMacAddress [/interface get [find where name=ether1] mac-address]
:local bridges [/interface bridge find]
:local macCounter 1
:put ("Original MAC of ether1: " . $originalMacAddress . "\n")
:foreach bridge in=$bridges do={
:local bridgeName ([/interface get $bridge name])
:local newMacAddress ""
:set locAdmMac ([:pick $originalMacAddress 0 1] . "2" . [:pick $originalMacAddress 2 15])
:if ( [ :len $macCounter; ] = 1 ) do={ :set macCounter ("0" . $macCounter) }
:set newMacAddress ($locAdmMac.$macCounter)
:put ("New MAC for " . $bridgeName . ": " . $newMacAddress)
/interface/bridge/set $bridge auto-mac=no admin-mac=$newMacAddress
:set macCounter ($macCounter + 1)
}
I appreciate feedback and improvement suggestions.