Hi
I really wish RouterOS will allow a DNS name in the PPTP client but alas that is not possible.
I found this script a while back on the net and forgive me for not keeping the source, however it doesn’t work
:log info (“script run”)
:global gwiname “abcd”
:global gwdnsname “abcd.domain.com”
:global gwliveip [:resolve $gwdnsname]
:global gwlocalip [/interface pptp-client get $gwiname connect-to]
:if ($gwlocalip != $gwliveip) do={ /interface pptp-client set [find name=$gwiname] connect-to=$gwliveip}
else {
:log info ("nothing changed for: ".$gwiname)
}
:log info (“end”)
Please can someone point me in the right direction…
Thanks
Mods: my post still pending moderation?
Try the version below instead. It has been modified by a few fingers over time and seems to be running OK in ROS 5.25
#Check current DNS resolution for PPTP Server
#Compare to existing IP value and change if necessary
#
:local progName "SetPPTPServer";
:local pptpServerName "www.pptpserverhere.com";
:local interfaceName "pptp-out1";
:global pptpserverip;
#Log start
:log info ("$progName: running");
#If no current IP value set one
:if ([ :typeof $pptpserverip ] = "nothing" ) do={ :global pptpserverip 0.0.0.0/0 }
#
#Resolve the name
#
:local resolvedIP [:resolve "$pptpServerName"];
#
#Log current and resolved values
#
:log info ("$progName: Current IP $pptpserverip - Resolved IP $resolvedIP");
#
#Compare the current and resolved values
#
:if ($pptpserverip = $resolvedIP) do={
#
#Values are the same - log accordingly
#
:log info ("$progName: No PPTP server IP address change necessary");
} else={
#
#Values are different - change interface value to resolved value and log accordingly
#
/interface pptp-client set [/interface pptp-client find name="$interfaceName"] connect-to="$resolvedIP";
:log info ("$progName: PPTP server dynamic IP address changed from $pptpserverip to $resolvedIP" );
:global pptpserverip $resolvedIP;
}
Thanks, the issue was the policy never had write
Something the obvious
One thing I don’t like with your revised script it never check the Interface connect-to only remembers the last change, so if you come from a reboot etc what will happen?
It was being run at startup with some other housekeeping which seemed to be taking care of it.