diff options
author | Christian Hesse <mail@eworm.de> | 2020-12-18 15:32:51 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2020-12-18 15:32:51 +0100 |
commit | be757722560df23796a3b0e3b290e6265b043431 (patch) | |
tree | 045a4911df6ec6a813f65546280955493d18631c /ipv6-update | |
parent | 62598b66531f7fe794300a298ee09849b317edab (diff) | |
parent | 3657830582c4e5b4c75050bc2145adee52fbef28 (diff) |
Merge branch 'ipv6-update'
Diffstat (limited to 'ipv6-update')
-rw-r--r-- | ipv6-update | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/ipv6-update b/ipv6-update index 4fdda3d..2224a11 100644 --- a/ipv6-update +++ b/ipv6-update @@ -17,15 +17,32 @@ :local Pool [ / ipv6 pool get [ find where prefix=$PdPrefix ] name ]; :local AddrList [ / ipv6 firewall address-list find where comment=("ipv6-pool-" . $Pool) ]; +:if ([ :len $AddrList ] = 0) do={ + :log info ("Missing ipv6 address list entry for ipv6-pool-" . $Pool . ", adding."); + / ipv6 firewall address-list add list=("ipv6-pool-" . $Pool) address=:: comment=("ipv6-pool-" . $Pool); + :set AddrList [ / ipv6 firewall address-list find where comment=("ipv6-pool-" . $Pool) ]; +} :local OldPrefix [ / ipv6 firewall address-list get $AddrList address ]; -# give the interfaces a moment to receive their addresses -:delay 2s; - -if ($OldPrefix != $PdPrefix) do={ +:if ($OldPrefix != $PdPrefix) do={ :log info ("Updating IPv6 address list with new IPv6 prefix " . $PdPrefix); / ipv6 firewall address-list set address=$PdPrefix $AddrList; + # give the interfaces a moment to receive their addresses + :delay 2s; + + :foreach ListEntry in=[ / ipv6 firewall address-list find where comment~("^ipv6-pool-" . $Pool . ",") ] do={ + :local ListEntryVal [ / ipv6 firewall address-list get $ListEntry ]; + :local Comment [ $ParseKeyValueStore ($ListEntryVal->"comment") ]; + + :local Address [ / ipv6 address find where from-pool=$Pool interface=($Comment->"interface") ]; + :if ([ :len $Address ] = 1) do={ + :set Address [ / ipv6 address get $Address address ]; + :log info ("Updating IPv6 address list with new IPv6 prefix " . $Address . " from interface " . ($Comment->"interface")); + / ipv6 firewall address-list set address=$Address $ListEntry; + } + } + :foreach Record in=[ / ip dns static find where comment~("^ipv6-pool-" . $Pool . ",") ] do={ :local RecordVal [ / ip dns static get $Record ]; :local Comment [ $ParseKeyValueStore ($RecordVal->"comment") ]; |