How To Create Multiple VLANs With One Command in Mikrotik..!

By | March 14, 2022

This is one of the very useful script in Mikrotik to create multiple vlan in one command . As we know in ISP or in enterprise network we use multiple vlans for separating our LAN segment between the customers so this script will save your time .Lets configure and verify ..!,

//Lets verify first ,Currently we have the vlans or not , As you can see the output given below we dont have any vlans .

[LD-MIKROTIK] > interface vlan print 
Flags: X - disabled, R - running 
 #   NAME                   MTU ARP             VLAN-ID INTERFACE   
 

//Lets create the VLAN range from 10-40 in mikrotik .

[LD-MIKROTIK] > :for x from=10 to=40 do={interface vlan add name=(
"vlan$x") vlan-id=$x interface=ether4}

//Lets Verify the VLANS are create or not ..!

[LD-MIKROTIK] > interface vlan print                              
Flags: X - disabled, R - running 
 #   NAME                   MTU ARP             VLAN-ID INTERFACE                
 0   vlan10                1500 enabled              10 ether4                   
 1   vlan11                1500 enabled              11 ether4                   
 2   vlan12                1500 enabled              12 ether4                   
 3   vlan13                1500 enabled              13 ether4                   
 4   vlan14                1500 enabled              14 ether4                   
 5   vlan15                1500 enabled              15 ether4                   
 6   vlan16                1500 enabled              16 ether4                   
 7   vlan17                1500 enabled              17 ether4                   
 8   vlan18                1500 enabled              18 ether4                   
 9   vlan19                1500 enabled              19 ether4                   
10   vlan20                1500 enabled              20 ether4                   
11   vlan21                1500 enabled              21 ether4                   
12   vlan22                1500 enabled              22 ether4                   
13   vlan23                1500 enabled              23 ether4                   
14   vlan24                1500 enabled              24 ether4                   
15   vlan25                1500 enabled              25 ether4                   
16   vlan26                1500 enabled              26 ether4                   
17   vlan27                1500 enabled              27 ether4                   
18   vlan28                1500 enabled              28 ether4                   
19   vlan29                1500 enabled              29 ether4                   
20   vlan30                1500 enabled              30 ether4                   
21   vlan31                1500 enabled              31 ether4                   
22   vlan32                1500 enabled              32 ether4                   
23   vlan33                1500 enabled              33 ether4                   
24   vlan34                1500 enabled              34 ether4                   
25   vlan35                1500 enabled              35 ether4                   
26   vlan36                1500 enabled              36 ether4                   
27   vlan37                1500 enabled              37 ether4                   
28   vlan38                1500 enabled              38 ether4                   
29   vlan39                1500 enabled              39 ether4                   
30   vlan40                1500 enabled              40 ether4                   

[LD-MIKROTIK] >        

Note:- The commands are in BOLD so you can copy and paste in your device ..!!

Leave a Reply

Your email address will not be published.