Script to add ports to a bridge

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 the variables outlined above and run the script.

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

    • 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 ...
    • 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 ...
    • 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 ...
    • Netonix Stacked Switches, Trunking and Access ports

      In this example we will stack two switches and trunk between them. We want to manage the switch from port 1 on Switch 1 and port 1 on Switch 2 via port 8 on Switch 1.   1. To configure the switch, set an IP address of 192.168.1.1/24 on your laptop ...
    • Bridge Two MikroTik Devices

        Need a wireless bridge between two buildings or a quick backhaul link? Have a pair of RouterBoard 411?s with their original Level 3 license lying around? Then great, you have exactly what you need to build a point to point link. ?What? I thought I ...