Mikrotik Cloud – a Dynamic DNS name and NTP service | Phy2Vir

An IT Blog covering anything from Physical to Virtual in I.T

Mikrotik Cloud – a Dynamic DNS name and NTP service

When you setup a router in a site that does not have a static public IP address, you would usually have to rely on 3rd party Dynamic DNS services to provide you access to the device/site without knowing the current IP address. This involved running scripts on the router to constantly update the DNS records.

Starting with RouterOS 6.14, Mikrotik have added a new feature called Cloud. When enabled, it will generate a DNS name based on your router’s serial number. It also provides an NTP service. This will avoid having to run scripts to update the ip address if you use ntp servers like ntp.pool.org and will not require any script to update the ip address at the 3rd party dynamic DNS name providers. Agreed, the generated DNS name is not a friendly one since it is based on the serial no but it should not be something you need to remember regularly since you can save the details in winbox.

To enable the Cloud service through command line:

/ip cloud set enabled=yes

To enable the NTP service (Update Time):

/ip cloud set update-time=yes

To view the settings and note the DNS Name:

/ip cloud print

The output will be similar to the below:

enabled: yes
update-time: yes
public-address: 0.0.0.0
dns-name: serialnumber.sn.mynetname.net
status: updated

Please note: Since v6.27 /ip cloud set enabled has changed to
/ip cloud set ddns-enabled
You can also enable it through Winbox or Webbox by clicking on the IP menu and click on Cloud.

Then tick the box marked Enabled and Update Time, if you require time sync. As soon as you click Apply, your DNS Name will be generated and it will show the current Public IP address

I personally like these new features and will definitely make use of them.

This seems to be a very popular post with daily hits. Don’t be shy! Let me know if you find it useful or if something needs to be changed! 🙂

UPDATE: I have written a blog post for using the Mikrotik Cloud IP DDNS when you have multiple ISPs. You can find it here.

 


14 Comments

  • om, tolong tanya, saya sdh setting IP-Cloud. Dan awalnya bisa masuk ke DDNS via webfig dgn domain router. Tp setelah bbrp menit, IP public berubah. Dan sy sudah tidak bisa akses webfig lagi. setelah setelah 30 menit lebih, baru webfig dgn domain router bisa diakses lagi. Kenapa ya om ? thx before

  • My friends says that:

    Dear sir, i would like to ask question, I’ve been setting the IP-Cloud. And initially could enter via webfig with DDNS domain router. But after a few minutes, the IP addresses change. And I can no longer access webfig. after 30 minutes more, webfig new domain with a router can be accessed again. Why is that happen? TIA

    • Hi,
      according to the Mikrotik IP/Cloud Wiki, the router checks for an IP change every 1 min. DDNS TTL is also 1 min so I am assuming that the Mikrotik router updates the DDNS IP address every minute, which I think is a lot. Other DDNS services will block you if you set such a high update IP frequency. What I can recommend is to run a script which forces and update of the DDNS every 30+ minutes.
      For example if the IP changes every 30 mins, I would set the script to run every 31 minutes.
      You can run the below command in the script to force the update:

      /ip cloud force-update

      Hope this helps.
      Thanks for visiting

  • Thanks for this post. I have enabled the time cloud as you have described. Now, how do I remove all the other scripts that may be running? I have done some checking in the scheduler and I appear to have a bunch of entries though the output of system script print only shows the script used for updating opendns. I currently have that script scheduled to run every hour as you have described. Can I stop that script and use this native feature?

    • Hi,
      if /system script print is empty, then the schedules you have could be trying to run in-existent scripts. You can check this by viewing the ON-EVENT item in the table resulted by /sytem scheduler print. That table entry shows the name of the script the scheduler will execute.
      Please bear in mind that OpenDNS and Cloud IP are different things. OpenDNS filters DNS requests to block unwanted sites whilst Cloud can be used to sync the Mikrotik Clock and provide a DDNS (Dynamic Domain Name Service) to access the router remotely.

      Thanks for visiting.

      • Thanks Brian. Problem solved. I first disabled and then removed the entries from /system scheduler
        This should ensure that I do not have redundant scripts running for updating NTP. I do not need to access my router from the outside so do not have any dynamic dns services setup.

  • Hi,

    My mikrotik use 2 internet interfaces (i.e ether1 & ether2) and use load balancing connection. The default internet connection is ether2 so IP cloud get the public IP from ether2.

    In this time I use ddns script to auto update server ddns no-ip.com. This script runs with scheduler. I want to change this script to auto update public IP to IP cloud server. My host of IP Cloud i.e xxxxx.sn.mynetname.net.

    How can I update my IP Cloud Host with customization my script “DDNS Auto Updater” bellow?

    # ——————————————–
    # DDNS Auto Updater Scripts
    # Custom script by StefDeddy

    # — Account DDNS ———–
    :local DDNSuser “my_user”
    :local DDNSpwd “my_pwd”
    :local DDNShost “my_ddns_host”
    # ———————————

    # — Interfaces Internet —-
    :local Inet1 “ether1”
    :local Inet2 “ether2”
    # ———————————

    :local currentIP1 “”
    :local currentIP2 “”
    :global previousIP
    :global IPDDNS
    :global IPInet1 “”
    :global IPInet2 “”
    :global IPInet3 “”

    :log info “————— start ———————”
    :log info “Hostname: $DDNShost”
    :log info “Inet1 interface: $Inet1”
    :log info “Inet2 interface: $Inet2”
    :log info “——————————————-”

    {
    :if ([/ping 8.8.8.8 interface=$Inet1 count=5] > 1) do={

    :local tmpIP [/ip address get [/ip address find interface=$Inet1 ] address];
    :set IPInet1 [:pick $tmpIP 0 [:find $tmpIP “/”]];
    :log info “>> IP Inet1: $IPInet1”
    :set currentIP1 $IPInet1
    /ip dns cache flush
    :set IPDDNS [:resolve $DDNShost]
    :log info “>> Current DDNS Host IP: $IPDDNS”
    :log info “>> Current public IP from $Inet1: $currentIP1”

    :if ($currentIP1 != $IPDDNS) do={

    :log info “——————————————-”
    :log info “>> Current public IP is not same with DDNS Host IP. Require update IP.”
    :set previousIP $IPDDNS
    :set IPDDNS $currentIP1
    :local url “http://dynupdate.no-ip.com/nic/update\3Fmyip=$currentIP1”
    :local DDNShostArray
    :set DDNShostArray [:toarray $DDNShost]

    :foreach host in=$DDNShostArray do={

    :log info “>> Sent update IP to DDNS Host..”
    /tool fetch url=($url . “&hostname=$host”) user=$DDNSuser password=$DDNSpwd mode=http keep-result=no;
    :log info “>> DDNS Host had been updated with IP $currentIP1”

    }

    } else={

    :log info “——————————————-”
    :log info “>> Current public IP is same with DDNS Host IP. Not require update IP.”

    }

    } else={

    :log info “>> $Inet1 is OFFLINE. Cannot update IP.”

    }

    :if ([/ping 8.8.8.8 interface=$Inet1 count=5] 1) do={

    :local tmpIP [/ip address get [/ip address find interface=$Inet2 ] address];
    :set IPInet2 [:pick $tmpIP 0 [:find $tmpIP “/”]];
    :log info “>> IP Inet2: $IPInet2”
    :set currentIP2 $IPInet2
    /ip dns cache flush
    :set IPDDNS [:resolve $DDNShost]
    :log info “>> Current DDNS Host IP: $IPDDNS”
    :log info “>> Current public IP from $Inet2: $currentIP2”

    :if ($currentIP2 != $IPDDNS) do={

    :log info “——————————————-”
    :log info “>> Current public IP is not same with DDNS Host IP. Require update IP.”
    :set previousIP $IPDDNS
    :set IPDDNS $currentIP2
    :local url “http://dynupdate.no-ip.com/nic/update\3Fmyip=$currentIP2”
    :local DDNShostArray
    :set DDNShostArray [:toarray $DDNShost]

    :foreach host in=$DDNShostArray do={

    :log info “>> Kirim update ke server DDNS: $host”
    /tool fetch url=($url . “&hostname=$host”) user=$DDNSuser password=$DDNSpwd mode=http keep-result=no;
    :log info “>> DDNS Host had been updated with IP $currentIP2”

    }

    } else={

    :log info “——————————————-”
    :log info “>> Current public IP is same with DDNS Host IP. Not require update IP.”

    }

    } else={

    :log info “>> $Inet2 is OFFLINE. Cannot update IP.”

    }

    }

    }
    :log info “————— end ———————–“

    • Hi,
      thanks for sharing this script. I am not sure I understand what you need. You want to run the script but instead of updating the no-ip DDNS ip, you want to update the xxxxx.sn.mynetname.net with the IP on interface1 and, if that is down, update with that of interface2? CloudIP does not use the same system as other DDNs providers. The cloudIP updates the IP of the DDNS(xxxx.sn.mynetname.net) by connecting to cloud.mikrotik.com on UDP port 15252. I do not know the string it sends. To fix your problem you can make a script that creates a default route to the ip address of cloud.mikrotik.com (currently 81.198.87.240) from the prefered internet connection. I will try to write a blog post on this.
      Hope I understood your question.

      • Hi Brian Farrugia,

        Thanks for your reply. Sorry for my bad english.
        Yes. You are right. I want to update the xxxxx.sn.mynetname.net with the IP on interface1 and, if that is down, update with that of interface2. If I don’t use script, how to implement this? Maybe I can use IP firewall NAT?

  • hi guys I have a problem with this can you help me?
    I didn’t know how to make topic nor did I fine an appropriate place to post it so if you can help me or direct me to the best location I would appreciate it. thanks
    first of all after I enable DDNS, in the status section it tells me that:
    “DDNS server received request from ip …(the public ip adress)… but your local ip was 192.168.1.6 (which is my gateway ip). DDNS service might not work.”
    and I can’t ping the DNS name it gives me 100% timeout then I’ve added this command:”/ip firewall filter add action=accept chain=input disabled=no dst-port=8291 protocol=tcp place-before=0″
    but this didnt help either! 😐
    what should I do?
    I have ip cameras in my work place and I want to watch them from home via this feature.
    can you help me?

    • Hi,
      The best place is to use the MikroTik forum.
      Can you do an nslookup of the ddns and check if the IP matches your current internet IP? Is MikroTik behind another firewall/router or is it the internet facing router?
      You may be dropping ICMP requests and that is why ping is not working.
      The rule you did is just to enable winbox access. Be careful before exposing that on the internet and make sure you have a good password.
      I also suggest updating your router to the latest version.
      Hope I was of some help.
      Thanks for leaving a comment.
      P.S you may want to have a look at this as well http://wp.me/p4leOf-4r

Post a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

  • Advertisements
  • Advertisement

    Advertisements
  • Connect with me

  • Site Menu

  • Follow me on Twitter

  • Advertisements