{"id":37,"date":"2015-04-26T19:56:42","date_gmt":"2015-04-26T16:56:42","guid":{"rendered":"https:\/\/amsd.go.ro\/wordpress\/?p=37"},"modified":"2021-09-07T11:27:01","modified_gmt":"2021-09-07T08:27:01","slug":"the-best-script-to-update-no-ip-dns","status":"publish","type":"post","link":"https:\/\/amsd.go.ro\/wordpress\/?p=37","title":{"rendered":"The best script to update No-IP DNS"},"content":{"rendered":"<p>This script was designed to utilize the No-IP Update API which offers direct access to No-IP&#8217;s DNS update system. This is the fixed version running on 6.x RouterOs version.<\/p>\n<p>1. Create a new script named <strong>no-ip_ddns_update<\/strong><\/p>\n<p>The following permissions are required for this script to run:<\/p>\n<ul>\n<li>write<\/li>\n<li>test<\/li>\n<li>read<\/li>\n<\/ul>\n<p>2. Paste the source code that appears below. Edit the user, password, hostname and interface info to match your setup.<\/p>\n<pre># -----------------------------------------------------------------------------------<br \/><br \/># No-IP User account info<br \/>:local noipuser \"&lt;user or email&gt;\"<br \/>:local noippass \"&lt;password&gt;\"<br \/><br \/># Set the hostname or label of network to be updated.<br \/># Hostnames with spaces are unsupported. Replace the value in the quotations below with your host names.<br \/># To specify multiple hosts, separate them with commas.<br \/>:local noiphost \"&lt;FQN hostname&gt;\"<br \/><br \/># Change to the name of interface that gets the dynamic IP address<br \/>:local inetinterface \"&lt;internet interface&gt;\"<br \/><br \/>#------------------------------------------------------------------------------------<br \/># No more changes need<br \/><br \/>:global previousIP<br \/><br \/>:if ([\/interface get $inetinterface value-name=running]) do={<br \/># Get the current IP on the interface<br \/>&nbsp;&nbsp; :local currentIP [\/ip address get [find interface=\"$inetinterface\" disabled=no] address]<br \/><br \/># Strip the net mask off the IP address<br \/>&nbsp;&nbsp; :for i from=( [:len $currentIP] - 1) to=0 do={<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :if ( [:pick $currentIP $i] = \"\/\") do={<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :set currentIP [:pick $currentIP 0 $i]<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;&nbsp; }<br \/><br \/># Get your previous IP address<br \/>&nbsp;&nbsp; :set previousIP [:resolve $noiphost]<br \/>&nbsp; &nbsp;<br \/>&nbsp;&nbsp; :if ($currentIP != $previousIP) do={<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :log info \"No-IP: Current IP $currentIP is not equal to previous IP $previousIP, update needed\"<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :set previousIP $currentIP<br \/><br \/># The update URL. Note the \"\\3F\" is hex for question mark (?). Required since ? is a special character in commands.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :local url \"http:\/\/dynupdate.no-ip.com\/nic\/update\\3Fmyip=$currentIP\"<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :local noiphostarray<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :set noiphostarray [:toarray $noiphost]<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :foreach host in=$noiphostarray do={<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :log info \"No-IP: Sending update for $host\"<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/tool fetch url=($url . \"&amp;hostname=$host\") user=$noipuser password=$noippass mode=http keep-result=no;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :log info \"No-IP: Host $host updated on No-IP with IP $currentIP\"<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;&nbsp; }&nbsp; else={<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :log info \"No-IP: Previous IP $previousIP is equal to current IP, no update needed\"<br \/>&nbsp;&nbsp; }<br \/>} else={<br \/>&nbsp;&nbsp; :log info \"No-IP: $inetinterface is not currently running, so therefore will not update.\"<br \/>}<br \/><br \/># --------------------------------------------------------------------------------------<\/pre>\n<p>3. Create a new scheduler entry to run this script every 5 mins.<\/p>\n<pre>system scheduler add comment=\"Update No-IP DDNS\" disabled=no interval=5m name=no-ip_ddns_update \\<br \/>on-event=no-ip_ddns_update policy=read,write,test<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This script was designed to utilize the No-IP Update API which offers direct access to No-IP&#8217;s DNS update system. This is the fixed version running on 6.x RouterOs version. 1. Create a new script named no-ip_ddns_update The following permissions are [&hellip;]<\/p>\n<div class=\"link-more\"><a href=\"https:\/\/amsd.go.ro\/wordpress\/?p=37#more-37\" class=\"more-link\">Continue reading &#10142; <span class=\"screen-reader-text\">The best script to update No-IP DNS<\/span><\/a><\/div>","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[20,12],"class_list":["post-37","post","type-post","status-publish","format-standard","hentry","category-technology","tag-ps_19","tag-ps_17"],"_links":{"self":[{"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=37"}],"version-history":[{"count":1,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/37\/revisions"}],"predecessor-version":[{"id":204,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/37\/revisions\/204"}],"wp:attachment":[{"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/amsd.go.ro\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}