Syed Jahanzaib Personal Blog to Share Knowledge !

November 14, 2012

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

For Personnel Reference

Following Guide contains two section as following …

  1. Howto configure NTP client in Mikrotik
  2. Howto configure NTP client in Ubuntu


Recently I received email from a friend who was annoyed by the Mikrotik Router board date/time resetting upon every reboot. He was using USERMAN with above 500 users, so it was a big problem for him for 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 upon reboot. 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 dont 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. That’s 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.

Note: I used in this example. you can use other ntp servers available near you.

 * Howto configure NTP in Mikrotik

/system clock
set time-zone-name=manual
# I set Timezone for KARACHI which is +5, you may change the time-zone according to your region
/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 6.x ------- (make sure DNS resolving/Internet is working in MT)
/system ntp client
set enabled=yes

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

After few seconds you will get the correct date/time … [or reboot the RB]

NOTE: For other countries, change the time zone according to there local region.

 * Howto configure NTP in Ubuntu

First install NTP service on Ubuntu sing below command,

apt-get -y install ntp ntpdate

Now copy PK Time zone to /etc [u may change it according to your timezone]

(You may copy time zone file according to your zone. Look in the folder to match)

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

Restart the NTP service

sudo /etc/init.d/ntp restart

After few seconds , system time will auto sync with the NTP servers.

Now type


to verify if time i now updated correctly

Additional TIP:

ntp.conf for local time server, un tested

root@ubuntu:~# #cat /etc/ntp.conf
driftfile /var/lib/ntp/ntp.drift
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
fudge startum 8
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
restrict ::1


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

  7. 1-do we have to change time zone in usermanager too?
    2- and can we use
    to set ntp client ?



    Comment by sam — June 8, 2017 @ 5:21 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 )

Connecting to %s

%d bloggers like this: