MIKROTIK - batch-create-vlan.sh: Difference between revisions

From IT-Arts.net
imported>Z
Created page with "Category:Post-It <nowiki> #!/bin/bash # # # GENERATE MIKROTIK TRUNK VLAN CONFIGURATION # # ##### VARIABLES # TRUNK INTERFACE INTERFACE="bond0" # VLAN RANGE TO CREATE VLA..."
 
m Text replacement - "Category:Wiki" to "Category:Wiki '''''[https://it-arts.net/index.php/Category:Wiki Return to Wiki Index]''''' "
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
[[Category:Post-It]]
[[Category:Wiki]]
 
'''''[https://it-arts.net/index.php/Category:Wiki Return to Wiki Index]'''''
 


  <nowiki>
  <nowiki>

Latest revision as of 07:04, 17 January 2026


Return to Wiki Index


#!/bin/bash
#
#
# GENERATE MIKROTIK TRUNK VLAN CONFIGURATION
#
#
##### VARIABLES
# TRUNK INTERFACE
INTERFACE="bond0"
# VLAN RANGE TO CREATE
VLAN_SEQUENCE="seq 2400 2499"


##### CREATE ALL BRIDGES
for i in `$VLAN_SEQUENCE`;
do
    echo "interface bridge add ageing-time=5m arp=enabled arp-timeout=auto auto-mac=yes comment=BRIDGE_VLAN_"$i" disabled=no fast-forward=yes forward-delay=15s igmp-snooping=no max-message-age=20s mtu=1500 name=bridge_vlan_"$i" protocol-mode=rstp transmit-hold-count=6 vlan-filtering=no"

done



##### CREATE ALL VLANS INTERFACES
for i in `$VLAN_SEQUENCE`;
do
    echo "interface vlan add arp=proxy-arp disabled=no loop-protect=on mtu=1500 name="$INTERFACE"_vlan_"$i" use-service-tag=yes interface=$INTERFACE vlan-id="$i" comment="$INTERFACE"_VLAN_"$i

done



##### ATTACH ALL VLANS TO BRIDGES
for i in `$VLAN_SEQUENCE`;
do
    echo "interface bridge port add auto-isolate=no bridge=bridge_vlan_"$i" broadcast-flood=yes comment=VLAN_"$i" disabled=no edge=auto frame-types=admit-all horizon=none ingress-filtering=no interface="$INTERFACE"_vlan_"$i" internal-path-cost=10 learn=auto path-cost=10 point-to-point=auto restricted-role=no restricted-tcn=no unknown-multicast-flood=yes unknown-unicast-flood=yes"

done




exit 0