aboutsummaryrefslogtreecommitdiffstats
path: root/ethernet-to-default
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-07-05 15:29:26 +0200
committerGravatar Christian Hesse <mail@eworm.de>2018-07-05 15:34:08 +0200
commite1f134ead584c7b2e9ed406f5520d7f1a23294aa (patch)
tree929660280fb0acc183401d7e59a40f1cd7e8992c /ethernet-to-default
parent1d99dc38ff1f583d6e46adc5d1ba3455114d53c1 (diff)
add scripts
Diffstat (limited to 'ethernet-to-default')
-rw-r--r--ethernet-to-default17
1 files changed, 17 insertions, 0 deletions
diff --git a/ethernet-to-default b/ethernet-to-default
new file mode 100644
index 0000000..ed86cc7
--- /dev/null
+++ b/ethernet-to-default
@@ -0,0 +1,17 @@
+# RouterOS script: ethernet-to-default
+# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
+#
+# reset ethernet interfaces to default bridge
+
+: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={
+ :log debug ("Interface " . $"interface-name" . " already connected to default bridge " $"bridge-default");
+ }
+}