mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
bridge-port-to-default: support different configurations
Just add something like this to your bridge ports: comment="default:br-ext,alt:br-intern"
This commit is contained in:
parent
ea4b739d00
commit
17f64b48af
2 changed files with 21 additions and 10 deletions
|
@ -4,15 +4,23 @@
|
|||
#
|
||||
# reset bridge ports 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");
|
||||
: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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
:global "safe-update-url" "";
|
||||
#:global "safe-update-url" "https://example.com/ros/safe-update/";
|
||||
|
||||
# This controls what configuration is activated by bridge-port-to-default.
|
||||
:global "bridge-port-to" "default";
|
||||
|
||||
# This is used to update AAAA records and firewall address-list.
|
||||
:global "ipv6-interface" "br-local";
|
||||
:global "ipv6-pool" "telekom";
|
||||
|
|
Loading…
Reference in a new issue