When you setup a VPN client, you need to input an IP to connect to. But what if the IP is not static?
Eks L2TP-Client setup
/interface l2tp-client
add connect-to=1.2.3.4 disabled=no ipsec-secret=my_secret name=home-server password=HardToGuess use-ipsec=yes user=RemoteSite
Connet-to can only contain IP and no DNS, so here is how I solved it. (There may be better solution)
I did setup a script that test the DNS every 24 hour and see if the IP changes, if so then update L2TP-client.
# get the current ip
:global currentIP
# get ip from DNS name
:local newIP [resolve my-server.dyndns.org]
# comapre old/new
:if ($newIP != $currentIP) do={
# set VPN remote IP
/interface l2tp-client set connect-to=$newIP [find name=home-server]
# log changes
:log info message="ip address $currentIP changed to $newIP"
# set current IP to new IP
:set currentIP $newIP
}
If someone has a better solution, please post ![]()