aboutsummaryrefslogtreecommitdiffstats
path: root/ethernet-to-default
blob: 419318c01f521df12f2860980de080235ef8eddd (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#
# 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");
  }
}