This is a hack-ish work-around for an IPsec setup with dynamic ips where one (or both) of the devices are running RouterOS.
update-ddns
- the script calls thefreemyip
API in order to update the A recordupdate-ipsec-ddns-entries
- this script changes all SA / peer addresses and adds the remote tunnel's address to a firewall list (optional)
- IPsec policies must use the same proposal (for each SA) and this proposal should not be used by any other peer/tunnel (even if the settings are similar just create a new one)
- IPsec peer must have a unique comment (to be used as identifier/name)
- Open
update-ddns.rsc
and chage the correspondingtoken
anddomain
.
Note: this is not universal and it currently works only for freemyip.com
. You should change the script to match your ddns provider.
- Open
update-ipsec-ddns-entries.rsc
and configure eachCHANGE_
entry.
ipsecProposal
- IPsec proposal name, that you want to updateddnsDst
- fqdn of the remote side of the tunnel (flip if both sides are running routeros)ddnsSrc
- fqdn of the local side of the tunnelpeerName
- comment of the peer you wish to updatealiasName
- firewall alias that you may want to add remote tunnel ip addresses to
-
Create a new script (with a name of your chosing) via
System -> Scripts
and give itread
andtest
permissions. -
Copy the contents of the
update-ddns.rsc
file in theSource
field. -
Create a new script (with a name of your chosing) via
System -> Scripts
and give itread
,policy
,sensitive
,write
andtest
permissions. -
Copy the contents of the
update-ipsec-ddns-entries.rsc
file in theSource
field. -
Create a new event (with a name of your chosing) via
System -> Scheduler
, give it permissionsread
,test
and enter the name you chose (in step 1) for your script in theOn Event
field.
Note: be careful, ddns providers usually have limits for updates
- Create a new event (with a name of your chosing) via
System -> Scheduler
, give it permissionsread
,policy
,sensitive
,write
,test
and enter the name (in step 2) you chose for your script in theOn Event
field.
Note: Frequent updates are not a problem as the script queries DNS names and updates the settings only when necessary.