blob: 1117c1d4b24dbbef641f79fa6dbf733faef568ad (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!rsc
# RouterOS script: bridge-port-to-default
# Copyright (c) 2013-2019 Christian Hesse <mail@eworm.de>
#
# reset bridge ports to default bridge
:global BridgePortTo;
:local Len ([ :len $BridgePortTo ] + 1);
:if ($Len = 1) do={
:delay 1s;
:set Len ([ :len $BridgePortTo ] + 1);
}
:foreach Interface in=[ / interface bridge port find where comment!="" ] do={
:foreach Comment in=[ :toarray [ / interface bridge port get $Interface comment ] ] do={
:if ([ :pick $Comment 0 $Len ] = ($BridgePortTo . ":")) do={
:local InterfaceName [ / interface bridge port get $Interface interface ];
:local BridgeDefault [ :pick $Comment $Len [ :len $Comment ] ];
:local BridgeCurrent [ / interface bridge port get $Interface bridge ];
:if ($BridgeDefault != $BridgeCurrent) do={
:log info ("Changing interface " . $InterfaceName . " to " . $BridgePortTo . " bridge " . $BridgeDefault);
/ interface bridge port set bridge=$BridgeDefault $Interface;
/ ip dhcp-client renew [ find where interface=$BridgeDefault ];
} else={
:log debug ("Interface " . $InterfaceName . " already connected to " . $BridgePortTo . " bridge " . $BridgeDefault);
}
}
}
}
|