Community discussions

MikroTik App
 
User avatar
Deslack
just joined
Topic Author
Posts: 10
Joined: Mon Apr 11, 2016 4:30 pm
Contact:

DDNS Update Script

Wed Apr 18, 2018 11:02 am

Hello guys, I've just made a DDNS update script for my several incoming dynamic IP internet connection (via PPPoE). Thought i'd share with you all.
/system script add name="noip-update" source="
:global noipUpdateProfile {
  "username"="YOUR_DDNS_USERNAME"
  "password"="YOUR_DDNS_PASSWORD"
  "pppoe-out1"="YOUR_DDNS_HOSTNAMEA.ddns.net"
  "pppoe-out2"="YOUR_DDNS_HOSTNAMEB.ddns.net"
  "pppoe-out3"="YOUR_DDNS_HOSTNAMEC.ddns.net"
}

:global noipUpdate do={
  :local url ("http://dynupdate.no-ip.com/nic/update\3Fmyip=" . $address . "&hostname=" . $hostname);
  :log info ("noip-update: " . $hostname . " => " . $address)
  /tool fetch url=$url user=$username password=$password mode=http keep-result=no
}

:global noipUpdateProfilePPP do={
  :global noipUpdate
  :local interfaceName [/interface get $interface name]
  $noipUpdate username=($profile->"username") password=($profile->"password") hostname=($profile->$interfaceName) address=$address
}
"
Then I would add a new PPP Profile, and set my PPPoE interface to use it. I set it to trigger on up, so it'll report to NOIP of the new interface's IP address for updating:
/ppp profile add name=noip-update on-up="
:global noipUpdateProfilePPP
:global noipUpdateProfile

:if ([ :typeof $noipUpdateProfilePPP ] = "nothing") do={
  /system script run noip-update;
}
:local address $"local-address"
$noipUpdateProfilePPP profile=$noipUpdateProfile interface=$interface address=$address
"
I'd love to know what you think. Hope that this benefits you all.

Who is online

Users browsing this forum: No registered users and 27 guests