aboutsummaryrefslogtreecommitdiffstats
path: root/update-gre-address
diff options
context:
space:
mode:
Diffstat (limited to 'update-gre-address')
-rw-r--r--update-gre-address25
1 files changed, 9 insertions, 16 deletions
diff --git a/update-gre-address b/update-gre-address
index e548f56..5261a4e 100644
--- a/update-gre-address
+++ b/update-gre-address
@@ -5,27 +5,20 @@
# update gre interface remote address with dynamic address from
# ipsec remote peer
-:global "gre-cert-prefix";
-:global "gre-int-prefix";
-
/ interface gre set remote-address=0.0.0.0 disabled=yes [ find where !running !disabled ];
:foreach peer in=[ / ip ipsec remote-peers find ] do={
:local id [ / ip ipsec remote-peers get $peer id ];
-
- :if ([ :pick $id 0 [ :len $"gre-cert-prefix" ] ] = $"gre-cert-prefix") do={
- :local name [ :pick $id [ :len $"gre-cert-prefix" ] [ :len $id ] ];
+ :local greint [ / interface gre find where comment=$id ];
+ :if ([ :len $greint ] > 0) do={
+ :local grename [ / interface gre get $greint name ];
+ :local addrold [ / interface gre get $greint remote-address ];
+ :local disabled [ / interface gre get $greint disabled ];
:local addrnew [ / ip ipsec remote-peers get $peer dynamic-address ];
- :local grename ($"gre-int-prefix" . $name);
- :local greint [ / interface gre find where name=$grename ];
- :if ([ :len $greint ] > 0) do={
- :local addrold [ / interface gre get $greint remote-address ];
- :local disabled [ / interface gre get $greint disabled ];
- :if ($addrnew != $addrold || $disabled = true) do={
- :log info ("Update remote address for interface " . $grename . " to " . $addrnew);
- / interface gre set remote-address=0.0.0.0 disabled=yes [ find where remote-address=$addrnew name!=$grename ];
- / interface gre set $greint remote-address=$addrnew disabled=no;
- }
+ :if ($addrnew != $addrold || $disabled = true) do={
+ :log info ("Update remote address for interface " . $grename . " to " . $addrnew);
+ / interface gre set remote-address=0.0.0.0 disabled=yes [ find where remote-address=$addrnew name!=$grename ];
+ / interface gre set $greint remote-address=$addrnew disabled=no;
}
}
}