From 7843574cd625babef3b7351f6be13867b8da7cac Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 9 Nov 2018 21:27:52 +0100 Subject: [PATCH] add script 'ip-addr-bridge' --- ip-addr-bridge | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 ip-addr-bridge diff --git a/ip-addr-bridge b/ip-addr-bridge new file mode 100644 index 0000000..924bba9 --- /dev/null +++ b/ip-addr-bridge @@ -0,0 +1,14 @@ +#!rsc +# RouterOS script: ip-addr-bridge +# Copyright (c) 2018 Christian Hesse +# +# enable or disable ip addresses based on bridge port state + +:foreach bridge in=[ / interface bridge find ] do={ + :local brname [ / interface bridge get $bridge name ]; + :if ([ / interface bridge port print count-only where bridge=$brname and inactive=no ] = 0) do={ + / ip address disable [ find where !dynamic interface=$brname ]; + } else={ + / ip address enable [ find where !dynamic interface=$brname ]; + } +}