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"

    
 
 
    • Related Articles

    • Script to add ports to a bridge

      # First, set port type i.e.: ether or sfp # This is for interfaces not named “ether” like SFP # Second set the bridge name # Then set ports in range form using SlavePortStart and SlavePortStop. Paste this into a terminal to create the script, change ...
    • RouterOS Script to Find iPhones

        This script will find devices in the DHCP Server leases list with a string in the device name. The purpose is to find iPhones so we can rate limit their upload, so as to not consume all our uplink bandwidth on slow connections by putting them on an ...
    • MikroTik CRS Switch Trunk and Access Port Quick and Dirty

      This is just a quick primer on creating a switch config with a trunk port and access ports.  More details can be found in my book "RouterOS by Example SecondEdition" by Steve Discher available here: http://www.ispsupplies.com/ISP-Services-LMT-B2     ...
    • Basic Script to Configure a Blank MikroTik Router

        I have developed a script you can simply paste into the router and it will configure everything for you and get you started on the right track. /ip address add address=192.168.1.1/24 disabled=no interface=ether2 add address=192.168.2.1/24 ...
    • Common Error with Simple Queues in MikroTik RouterOS

      Simple Queues don’t work properly... I have heard this more than once, my MikroTik RouterOS Simple Queues don't work properly.  In a simple queue, “target” option is the only option that determines the flow direction of a simple queue.  Since the ...