MIKROTIK - batch-create-vlan.sh

From Wiki.IT-Arts.net
Revision as of 13:07, 1 May 2024 by 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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


#!/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