System Clock and NTP
|Document revision:||NaN (Mon Jul 10 13:21:55 GMT 2006)|
System clock allows router to track current date and time.
SpecificationsLicense required: Level1
Submenu level: /system clock
Property Descriptiondate (text) - date in format "mm/DD/YYY"dst-active (read-only: yes | no; default: no) - whether the Daylight Saving Time is currently acitve time (time) - time in format "HH:MM:SS"time-zone (text) - UTC timezone in format "+HH:MM" or "-HH:MM"
It is recommended that you reboot the router after time change to obviate the possible errors in time measurments and logging.
Date and time settings become permanent and effect BIOS settings.
If NTP update gives time shifted by 1 hour, although the time zone is set correctly, you may want to adjust the DST setting in /system clock dst menu.
To view the current date and time settings:
[admin@Local] system clock> print time: 08:26:37 date: nov/18/2004 time-zone: +00:00 dst-active: no [admin@Local] system clock>
To set the system date and time:
[admin@Local] system clock> set date=nov/22/2022 time=11:10:21 time-zone=+0 [admin@Local] system clock> print time: 11:10:25 date: nov/22/2022 time-zone: +00:00 dst-active: no [admin@Local] system clock>
System Clock DST adjustmentSubmenu level: /system clock dst
In most countries, a Daylight Saving Time regime is activated in spring and deactivated in autumn. This configuration menu provides DST adjustment facility, to drift the timezone according to your local legislation and practice.
Property Descriptiondst-delta (text; default: +01:00) - UTC timezone drift in format "+HH:MM" or "-HH:MM" to be added to the local timezone during DST perioddst-end (date time) - date and time when DST ends (when the delta is to be dropped).dst-start (date time) - date and time when DST begins (when the delta is to be applied).
To make DST zonechange active from mar/27/2005 03:00:00 till oct/30/2005 03:00:00:
[admin@MikroTik] system clock dst> set dst-start="mar/27/2005 03:00:00" dst-end="oct/30/2005 03:00:00" [admin@MikroTik] system clock dst> print dst-delta: +01:00 dst-start: mar/27/2005 03:00:00 dst-end: oct/30/2005 03:00:00 [admin@MikroTik] system clock dst>
NTP protocol allows synchronizing time among computers in network. It is good if there is an internet connection available and local NTP server is synchronized to correct time source. List of publec NTP servers is available at http://www.eecis.udel.edu/~mills/ntp/servers.html
SpecificationsPackages required: ntp
License required: Level1
Submenu level: /system ntp
Standards and Technologies: NTP version 3 (RFC 1305)
Hardware usage: Not significant
Network Time Protocol (NTP) is used to synchronize time with some NTP servers in a network. MikroTik RouterOS provides both - NTP client and NTP server.
NTP server listens on UDP port 123
NTP client synchronizes local clock with some other time source (NTP server). There are 4 modes in which NTP client can operate at:
- unicast (Client/Server) mode - NTP client connects to specified NTP server. IP address of NTP server must be set in ntp-server and/or second-ntp-server parameters. At first client synchronizes to NTP server. Afterwards client periodically (64..1024s) sends time requests to NTP server. Unicast mode is the only one which uses ntp-server and second-ntp-server parameters.
- broadcast mode - NTP client listens for broadcast messages sent by NTP server. After receiving first broadcast message, client synchronizes local clock using unicast mode, and afterwards does not send any packets to that NTP server. It uses received broadcast messages to adjust local clock.
- multicast mode - acts the same as broadcast mode, only instead of broadcast messages (IP address 255.255.255.255) multicast messages are received (IP address 18.104.22.168).
- manycast mode - actually is unicast mode only with unknown IP address of NTP server. To discover NTP server, client sends multicast message (IP 22.214.171.124). If NTP server is configured to listen for these multicast messages (manycast mode is enabled), it replies. After client receives reply, it enters unicast mode and synchronizes to that NTP server. But in parallel client continues to look for more NTP servers by sending multicast messages periodically.
ClientSubmenu level: /system ntp client
Property Descriptionenabled (yes | no; default: no) - whether the NTP client is enabled or notmode (unicast | broadcast | multicast | manycast; default: unicast) - NTP client modeprimary-ntp (IP address; default: 0.0.0.0) - specifies IP address of the primary NTP serversecondary-ntp (IP address; default: 0.0.0.0) - specifies IP address of the secondary NTP serverstatus (read-only: text) - status of the NTP client:
error - there was some internal error starting NTP service (please, try to restart (disable and enable) NTP service)
started - NTP client service is started, but NTP server is not found, yet
failed - NTP server sent invalid response to our NTP client (NTP server is not synchronized to some other time source)
reached - NTP server contacted. Comparing local clock to NTP server's clock (duration of this phase is approximately 30s)
timeset - local time changed to NTP server's time (duration of this phase is approximately 30s)
synchronized - local clock is synchronized to NTP server's clock. NTP server is activated
using-local-clock - using local clock as time source (server enabled while client disabled)
To enable the NTP client to synchronize with the 126.96.36.199 server:
[admin@MikroTik] system ntp client> set enabled=yes primary-ntp=188.8.131.52 [admin@MikroTik] system ntp client> print enabled: yes mode: unicast primary-ntp: 184.108.40.206 secondary-ntp: 0.0.0.0 status: synchronized [admin@MikroTik] system ntp client>
ServerSubmenu level: /system ntp server
Property Descriptionbroadcast (yes | no; default: no) - whether NTP broadcast message is sent to 255.255.255.255 every 64senabled (yes | no; default: no) - whether the NTP server is enabledmanycast (yes | no; default: yes) - whether NTP server listens for multicast messages sent to 220.127.116.11 and responds to themmulticast (yes | no; default: no) - whether NTP multicast message is sent to 18.104.22.168 every 64s
NTP server activities only when local NTP client is in synchronized or using-local-clock mode.
If NTP server is disabled, all NTP requests are ignored.
If NTP server is enabled, all individual time requests are answered.
CAUTION! Using broadcast, multicast and manycast modes is dangerous! Intruder (or simple user) can set up his own NTP server. If this new server will be chosen as time source for your server, it will be possible for this user to change time on your server at his will.
To enable NTP server to answer unicast requests only:
[admin@MikroTik] system ntp server> set manycast=no enabled=yes [admin@MikroTik] system ntp server> print enabled: yes broadcast: no multicast: no manycast: no [admin@MikroTik] system ntp server>
Time ZoneSubmenu level: /system clock
NTP changes local clock to UTC (GMT) time by default.
Time zone is specified as a difference between local time and GMT time. For example, if GMT time is 10:24:40, but correct local time is 12:24:40, then time-zone has to be set to +2 hour:
[admin@MikroTik] system clock> print time: dec/24/2003 10:24:40 time-zone: +00:00 [admin@MikroTik] system clock> set time-zone=+02:00 [admin@MikroTik] system clock> print time: dec/24/2003 12:24:42 time-zone: +02:00 [admin@MikroTik] system clock>
If local time is before GMT time, time-zone value will be negative. For example, if GMT is 18:00:00, but correct local time is 15:00:00, time-zone has to be set to -3 hours:
[admin@MikroTik] system clock> set time-zone=-3 [admin@MikroTik] system clock> print time: sep/24/2004 08:13:28 time-zone: -03:00 [admin@MikroTik] system clock>