Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 15394

Scripting • Re: CRS - VLAN - Add untagged interfaces via script

$
0
0
I do not set the separator out of scope,
it is you who did not copy the { }, if there are, there must be a reason.
It is logical that it gives you error if you do not copy exactly.

Code:
{...         :if ($i = 0) do={ :set separator "," }^--- this is a clue you did not put { at the beginning

for add also all type of physical ethernet is better this regular experssion than only "sfp*" :
Code:
default-name~"(combo|ether|sfp)*"

Scripts here are much cleaner then either of what I do.. what I do does save time but still not as clean as those..

one I use all the time to REMOVE ALL TAGS!
Code:
/interface bridge vlan :local iface "sfp-sfpplus4"; # put here the interface you want to remove# on next row, set your conditions:foreach i in=[find where ((vlan-ids>=10 and vlan-ids<=199) || (vlan-ids>=200 and vlan-ids<=1703))] do={    # here goes magic    set $i tagged=([:pick [get $i tagged] 0 [:find [get $i tagged] $iface +1]],[:pick [get $i tagged] ([:find [get $i tagged] $iface -1] + 1) [:len [get $i tagged]]])}
These scripts are much cleaner for the interface.. for tagging.. (rex,sirbryan combo)
Code:
{    /interface ethernet    :global InterfaceList ""    :global separator ""    :foreach i,Interface in=[ find where default-name~"ether*|sfp*" ] do={        :set $InterfaceList "$InterfaceList$separator$[ get $Interface name ]"        :if ($i = 0) do={ :set separator "," }    }    :put $InterfaceList    /interface bridge vlan set tagged=$InterfaceList [ find where vlan-ids=140 ]}


Mine I have to mess with all the time.. but still better then messing with them one by one.. mine is below..
Code:
set [find where (vlan-ids>="201" and vlan-ids<="290")] tagged=sfp-sfpplus1,sfp-sfpplus4,sfp1,sfp2,sfp3,sfp4,sfp5,sfp6,sfp7,sfp8,sfp9,sfp10,sfp11,sfp12,sfp13,sfp14,sfp15,sfp16,sfp17,sfp18,sfp19,sfp20
Not really even a script.. just did what I wanted it too.. lol

Im going to mash these around and try and improve the ones im using..

Amazing what you guys put together..

Statistics: Posted by joshhboss — Fri Jan 26, 2024 6:33 pm



Viewing all articles
Browse latest Browse all 15394

Trending Articles