PPP Dial-out server with dynamic ip address [SOLVED]

Hi,
while I am trying to setup some pptp client interfaces, I need to specify the pptp server host with its dynamic dns name (server by dyndns.org), and not the ip address, which is changing all the time by the host server ISP.
In the winbox setup window (new interface, dial out tab, connect to field), I do indeed use the dyndns host name, but mikrotik resolves it immediatelly, to the current ip address.
How can I keep this un-resolved, so whenever the link falls, it will make a dns lookup to find the current dynamic address and use it to dial out to the server?
I searched a lot, but all I have found was the dyn dns update script and scheduler command (which is to update the dns service).
Can anyone please help?
thanks a lot!
darengr

You can’t natively. You’ll have to adapt that dyndns to not update a dyndns record, but to instead change the IP address of the server in your configuration. Run it scheduled every 10 minutes or something.

but to instead change the IP address of the server in your configuration

many thanks for quick reply, however, although I think I can moderatelly understand that script, how can I do the above? any references or hints as to where the info for the dial out host resides?
regards!
ps It could make an nice suggestion for the next version of router os. I have seen software that collects ip cams (that usually are on dynamic addresses) and it has a little tickbox to use dns, and you can type the un-resolved dns name, instead of the ip.

Something like this, completely untested:

:local serverName "edit.me.to.the.server.instance.name";
:global pptp-ip;
:if ([ :typeof $pptp-ip ] = "nothing" ) do={ :global pptp-ip 0.0.0.0/0 }
:local current [:resolve "pptp.dnsname.com"];
:if ($pptp-ip = $current) do={
  :log "No PPTP server IP address change necessary";
} else={
  /interface pptp-client set [/interface pptp-client find name="$serverName"] connect-to="$current";
  :global pptp-ip $current;
}

:smiley:
fewi, many-many thanks, I will try it as soon as possible and let you know whether it is ok!
have a nice weekend and regards from athens!

Well, this was tested out fine! Here is my version (and my first script!):

:log info ("Start check for possible change of PPTP server dynamic IP address");
:local pptpServerDnsName "your.dynamicDnsName.com";
:local interfaceName "pptp-out1";
:global pptpserverip;
:if ([ :typeof $pptpserverip ] = "nothing" ) do={ :global pptpserverip 0.0.0.0/0 }
:local current [:resolve "$pptpServerDnsName"];
:log info ("$pptpserverip" . " vs " . "$current");
:if ($pptpserverip = $current) do={
  :log info ("No PPTP server IP address change necessary");
} else={
  /interface pptp-client set [/interface pptp-client find name="$interfaceName"]   connect-to="$current";
  :log info ("PPTP server dynamic IP address changed from " . "$pptpserverip" . " to " . "$current" );
  :global pptpserverip $current;
}

Next I will try to schedule it. Hope this helps also somebody else, with dynamic addresses on the server side :wink:
Many thanks, fewi!
darengr

Can somone please confirm this works and suggest any better coding / method?

@ first i wish a Happy new Year at all :slight_smile:

Here is an / script to resolve hostnames through the internet !

The Script works in ROS 4.16

/system script

add name=dyndns policy=\
    ftp,reboot,read,write,policy,test,winbox,password source="# Dynamic DNS Up\
    date / Simple Edition\r\
\n:global pptpinterfacename \"pptp-out1\"\r\
\n:global pptpdnsname \"dyndns.dyn.org\"\r\
\n:global pptpdnsip [:resolve \$pptpdnsname]\r\
\n:global currentip [/interface pptp-client get \$pptpinterfacename connect-to]\r\
\n:if (\$currentip != \$pptpdnsip) do={ /interface pptp-client set [find name=\$pptpinterfacename] connect-to=\$pptpdnsip}\r\
\n\r\
    \n}"

Please change pptpinterfacename default is “pptp-out1” and change the pptpdnsname what you will resolve !

And then set the sheduler.

That was all :slight_smile:

Best regards

Lominus

Thank You all for many usefull posts in this topic. Thank You fewi for many usefull posts generally…

Best Regards!

Yep, I have used this on many of my sites and works a charm,
cheerz