2020-09-18 09:00:27 +00:00
|
|
|
#!rsc by RouterOS
|
2018-11-09 20:27:52 +00:00
|
|
|
# RouterOS script: ip-addr-bridge
|
2023-01-02 22:33:49 +00:00
|
|
|
# Copyright (c) 2018-2023 Christian Hesse <mail@eworm.de>
|
2020-06-19 20:17:42 +00:00
|
|
|
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
2018-11-09 20:27:52 +00:00
|
|
|
#
|
|
|
|
# enable or disable ip addresses based on bridge port state
|
2020-03-27 20:46:44 +00:00
|
|
|
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ip-addr-bridge.md
|
2018-11-09 20:27:52 +00:00
|
|
|
|
2022-05-10 13:03:30 +00:00
|
|
|
:foreach Bridge in=[ /interface/bridge/find ] do={
|
|
|
|
:local BrName [ /interface/bridge/get $Bridge name ];
|
|
|
|
:if ([ :len [ /interface/bridge/port/find where bridge=$BrName ] ] > 0) do={
|
|
|
|
:if ([ :len [ /interface/bridge/port/find where bridge=$BrName and inactive=no ] ] = 0) do={
|
|
|
|
/ip/address/disable [ find where !dynamic interface=$BrName ];
|
2018-11-26 10:12:24 +00:00
|
|
|
} else={
|
2022-05-10 13:03:30 +00:00
|
|
|
/ip/address/enable [ find where !dynamic interface=$BrName ];
|
2018-11-26 10:12:24 +00:00
|
|
|
}
|
2018-11-09 20:27:52 +00:00
|
|
|
}
|
|
|
|
}
|