Community discussions

MikroTik App
 
tysongoulding
just joined
Topic Author
Posts: 3
Joined: Fri Dec 06, 2019 1:46 am

Dot1x script to enable/disable interfaces

Tue Aug 23, 2022 6:58 pm

Hello all,

Would like a script that can disable/enable the server interface based on the active vlan.
Version 7.2.3

For example:
server interface ether2 has a vlan of 2200
server interface ether3 has a vlan of 2200
server interface ether5 has a vlan of 200

Want to be able to disable ether2/ether3 based on vlan2200

Believe I need a :foreach command to make this work.

Need to get the interface from:
/interface/dotx1x/server/active print where vlan-id-2200

Use interface above to disable:
/interface/dot1x/server print

Idea CLI
interface dot1x server disable [/interface dot1x server active find vlan-id=2200]
interface dot1x server enable [/interface dot1x server find where disabled] working

Output Samples:
example.png
Thanks in advanced!
You do not have the required permissions to view the files attached to this post.
 
tysongoulding
just joined
Topic Author
Posts: 3
Joined: Fri Dec 06, 2019 1:46 am

Re: Dot1x script to enable/disable interfaces

Wed Aug 24, 2022 4:53 pm

/interface/dot1x/server/active
:foreach i in=[find where vlan-id=2200] do={
:local int [get $i interface]
/interface/dot1x/server disable interface=$int
}
Found another issue, not able to disable interface, can only disable numbers
/interface/dot1x/server/active
:foreach a in=[print where vlan-id=2200] do={
:local int [get $a interface]
}
/interface/dot1x/server
:foreach b in=[find where interface=$int] do={
:local n [get $b number]
}
/interface dot1x server disable number=$n
Do not know how to combine these, even if these work

Who is online

Users browsing this forum: JDF, patrikg, rextended and 27 guests