I’ve got a small solution for you, but I am still working on the “automation” of the script. Right now, this script disconnects and re-connects the VPN every time it runs.
But you are welcome to use it :
:set [/interface pptp-client set nameofVPNinterface connect-to=[:resolve http://www.url.com]
If anyone can help, I’m trying to upgrade this script so that it will check to se if the IP has changed, and will only update if it has changed.
I’ve tried this, but its not working :
:if [/interface pptp-client get nameofVPNinterface connect-to=] = [:resolve http://www.url.com] do nothing else :set [/interface pptp-client set nameofVPNinterface connect-to=[:resolve http://www.url.com]
My syntax is all wrong, any ideas would be appreciated.
Try this… it resolves DNS and if different than what’s in connect-to it will update it, otherwise nothing happens. Be aware though that if DNS is wrong or unresolvable it might hose things. It might be adviseable to check more parameters first.
:if ($dtdns-newd1 != $dtdns-oldd1) do={
:log info ("VPN Info: Actualizando Peer VPN")
/ip ipsec peer set [find address=($dtdns-oldd2 . "/32:500")] address=$dtdns-newd2
/ip ipsec policy set [find sa-dst-address=($dtdns-oldd2)] sa-dst-address=$dtdns-newd2
/tool netwatch set [find host=($dtdns-oldd2)] host=$dtdns-newd2
/system scheduler set [find comment=("Estado_VPN")] disable=no
:global dtdns-oldd2 $dtdns-newd2
/tool e-mail send from=DIRHEL_AR_MKT@dirhel.com to=mail1@domain.com server=TTT.XXX.YYY.ZZZ subject=([/system identity get name] . " " . [/system clock get date] . " " . [/system clock get time] . " PEER VPN ACTUALIZADO") body=("Administrador: La configuracion IPSEC del Equipo central ha sido modificada")