RouterOS Script to Set Master Port

RouterOS Script to Set Master Port

 

This script will set a series of ports to use one port as their master. Paste the script into a terminal or paste it to a notepad file named .rsc and import it. Edit the variables as described in the script and then run it.

      system script
add name="Set Ports" owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive source="#\r\
    \n#\r\
    \n# Set master port\r\
    \n# Then set slave port type i.e.: ether or sfp \r\
    \n# This is for interfaces not named \93ether\94 like SFP\r\
    \n# Then set ports in range form using SlavePortStart and SlavePortStop.\r\
    \n:global MasterPort \"ether24\"\r\
    \n:global PortType \"ether\"\r\
    \n:global SlavePortsStart \"1\"\r\
    \n:global SlavePortsStop \"9\"\r\
    \n:for i from=\$SlavePortsStart to=\$SlavePortsStop do={\r\
    \n/interface ethernet set (\$PortType . \$i) master-port=\$MasterPort\r\
    \n}"

    

This script will clear any master ports and set all masters to none.

      
/system script
add name="Clear Ports" owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive source=\
    "/interface ethernet\r\
    \nset [find] master=none"