2018-09-26 22:18:43 +00:00
|
|
|
#!rsc
|
2018-08-27 08:16:10 +00:00
|
|
|
# RouterOS script: bridge-port-to-default
|
2018-07-05 13:29:26 +00:00
|
|
|
# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
|
|
|
|
#
|
2018-08-27 08:16:10 +00:00
|
|
|
# reset bridge ports to default bridge
|
2018-07-05 13:29:26 +00:00
|
|
|
|
2018-10-04 11:56:09 +00:00
|
|
|
:global "bridge-port-to";
|
|
|
|
|
|
|
|
:local "len" ([ :len $"bridge-port-to" ] + 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 ] = ($"bridge-port-to" . ":")) do={
|
|
|
|
:local "interface-name" [ / interface bridge port get $interface interface ];
|
|
|
|
:local "bridge-default" [ :pick $comment $len [ :len $comment ] ];
|
|
|
|
:local "bridge-current" [ / interface bridge port get $interface bridge ];
|
|
|
|
:if ($"bridge-default" != $"bridge-current") do={
|
|
|
|
:log info ("Changing interface " . $"interface-name" . " to " . $"bridge-port-to" . " bridge " . $"bridge-default");
|
|
|
|
/ interface bridge port set bridge=$"bridge-default" $interface;
|
|
|
|
/ ip dhcp-client renew [ find where interface=$"bridge-default" ];
|
|
|
|
} else={
|
|
|
|
:log debug ("Interface " . $"interface-name" . " already connected to " . $"bridge-port-to" . " bridge " . $"bridge-default");
|
|
|
|
}
|
|
|
|
}
|
2018-07-05 13:29:26 +00:00
|
|
|
}
|
|
|
|
}
|