Syed Jahanzaib Personal Blog to Share Knowledge !

November 14, 2012

Howto configure NTP client in Mikrotik / Ubuntu for Asia/Karachi

For Personnel Reference

Recently I received email from a friend who was annoyed by the RB date/time resetting upon every reboot. He had USERMAN with above 500 users, so it was a big problem from the accounting perspective. He thought RB also have the battery to save the time/data😀 , He asked me how he can replace the battery :p
Routerboards do not have an internal clock to keep time between reboots. You have to configure NTP client to obtain ip from Time Server. Following are the scripts to update your NTP client and set time zone to +5 (for Karachi/Pakistan). Make sure you have enabled internet access on the router before configuring NTP.After configuring NTP, you wont have to manually configure the time CLOCK. This is very crucial for mikrotik to obtain correct time specially for LOG purposes and if you are doing user accounting by using Radius Server like USERMAN on it. For example if the RB reboots and the date/time resets to previous dates, then it can create lot of problems for user accounting. Thats why NTP client ensures that you always get the proper date/time upon every reboot or in routine. Use the following script to setup NTP client.

/system clock
set time-zone-name=manual
/system clock manual
set dst-delta=+00:00 dst-end="jan/01/1970 00:00:00" dst-start="jan/01/1970 00:00:00" time-zone=+05:00

# For Mikrotik 5.x syntax
/system ntp client
set enabled=yes mode=unicast primary-ntp= secondary-ntp=

# For Mikrotik 6.x
#/system ntp client
#set enabled=yes primary-ntp= secondary-ntp=

It is recommended that you reboot the router after time change. After few seconds you will get the correct date/time …

For other countries, change the timezone according to there local timings.



Howto configure NTP in Ubuntu

First install NTP service on Ubuntu sing below command,

apt-get install ntp

Now edit ntp.conf file to add NTP server.

nano /etc/ntp.conf

Add this parameter anywhere in this file.


Save & exit.

Now copy PK Time zone to /etc

cp /usr/share/zoneinfo/Asia/Karachi /etc/localtime

Use the below command to update the time.

ntpdate -u

Now type


to verify time.


Syed Jahanzaib


  1. i’m kevin Please i need help i use rb450g(mipsbe) i delete all file and now when i open userman is open but not with all option.
    iwan to know how to restore with initial file.

    Comment by kevin — April 4, 2013 @ 3:25 AM

  2. thanks my teacher

    Comment by spidernet2013 — September 18, 2013 @ 3:20 PM

  3. we thank Allah for giving us YOU!

    Comment by Day-Day Ahmed — December 31, 2013 @ 12:46 AM

  4. after putting above settings still not working please solve the issue RB750GL

    Comment by Muhammad Nauman — May 13, 2014 @ 10:03 AM

  5. hi,
    i configured as explained above but time is not updating..please assist..i have an RB 1100 running ROS 6.14

    Comment by Michael — June 11, 2014 @ 6:19 AM

  6. Hi, for people who have trouble with ntp / sntp mikrotik not working, try this script. I have been searching, trying, upgrading all day, but did not get the mikrotik client to work properly, so I have made this simple script, which does the job, without using ntp or sntp. greetings, Richard.

    # This script copyright by Richard Kloostra
    # You can use, modify, delete free of any charge
    # Please submit modifications back to me.
    # last modified, Dec 12 2014 , v1.0
    # Applies to ROS 6.23 / RB1100
    # Credit to
    # Variables
    :local newgmtmonstring (“newgmtmonstring”.”txt”)
    :local gmtmonurl “\\b”
    :local mon

    :local newgmtdaystring (“newgmtdaystring”.”txt”)
    :local gmtdayurl “\\d”
    :local day

    :local newgmtyearstring (“newgmtyearstring”.”txt”)
    :local gmtyearurl “\\Y”
    :local year

    :local newgmttimestring (“newgmttimestring”.”txt”)
    :local gmttimeurl “\\H:\\M:\\S”
    :local gmttime

    :local newgmtoffset (“newgmtoffset”.”txt”)

    # Script
    /tool fetch mode=http url=$gmtmonurl dst-path=$newgmtmonstring
    :set mon [/file get ($newgmtmonstring) contents]
    :log info ($mon)

    /tool fetch mode=http url=$gmtdayurl dst-path=$newgmtdaystring
    :set day [/file get ($newgmtdaystring) contents]
    :log info ($day)

    /tool fetch mode=http url=$gmtyearurl dst-path=$newgmtyearstring
    :set year [/file get ($newgmtyearstring) contents]
    :log info ($year)

    /tool fetch mode=http url=$gmttimeurl dst-path=$newgmttimestring
    :set gmttime [/file get ($newgmttimestring) contents]
    :log info ($gmttime)

    /system clock set date=”$mon/$day/$year” time=”$gmttime”;

    Comment by dqbl — December 13, 2014 @ 4:53 AM

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: