2020-09-18 11:00:27 +02:00
|
|
|
#!rsc by RouterOS
|
2018-11-09 21:27:52 +01:00
|
|
|
# RouterOS script: ip-addr-bridge
|
2022-01-01 21:38:15 +01:00
|
|
|
# Copyright (c) 2018-2022 Christian Hesse <mail@eworm.de>
|
2020-06-19 22:17:42 +02:00
|
|
|
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
2018-11-09 21:27:52 +01:00
|
|
|
#
|
|
|
|
# enable or disable ip addresses based on bridge port state
|
2020-03-27 21:46:44 +01:00
|
|
|
# https://git.eworm.de/cgit/routeros-scripts/about/doc/ip-addr-bridge.md
|
2018-11-09 21:27:52 +01:00
|
|
|
|
2022-05-10 15:03:30 +02: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 11:12:24 +01:00
|
|
|
} else={
|
2022-05-10 15:03:30 +02:00
|
|
|
/ip/address/enable [ find where !dynamic interface=$BrName ];
|
2018-11-26 11:12:24 +01:00
|
|
|
}
|
2018-11-09 21:27:52 +01:00
|
|
|
}
|
|
|
|
}
|