routeros-scripts/bridge-port-to-default

19 lines
881 B
Text
Raw Normal View History

#!rsc
# RouterOS script: bridge-port-to-default
2018-07-05 13:29:26 +00:00
# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
#
# reset bridge ports to default bridge
2018-07-05 13:29:26 +00:00
:foreach interface in=[ / interface bridge port find where comment~"^default:" ] do={
:local comment [ / interface bridge port get $interface comment ];
:local "interface-name" [ / interface bridge port get $interface interface ];
:local "bridge-default" [ :pick $comment 8 [ :len $comment ] ];
:local "bridge-current" [ / interface bridge port get $interface bridge ];
:if ($"bridge-default" != $"bridge-current") do={
:log info ("Reverting interface " . $"interface-name" . " to default bridge " . $"bridge-default");
/ interface bridge port set bridge=$"bridge-default" $interface;
} else={
2018-08-27 08:11:13 +00:00
:log debug ("Interface " . $"interface-name" . " already connected to default bridge " . $"bridge-default");
2018-07-05 13:29:26 +00:00
}
}