NTP server

NTP server or Network Time Protocol server is something that you should REALLY have in your network (it works on port 123, UDP, as source and destination).
But we have a additional problem connected to time, and that is “Daylight saving time” (DST), or adding and substracting 60min two times per year.
If you have a NTP server in network (as you should) which takes its time directly from satellite (GPS sync), you may get exactly such a problem with +/-60min. Such adjustments are than done on Linux NTP servers which take time from GPS device :
Because NTP is based on UTC which does not have a daylight savings time period, a switchover is not necessary inside the NTP system. The operation systems of servers and clients are solely responsible for switching from/to DST.
With adjustment of out time zone and locality, we are setting up DST (or not), and Linux server automatically adjusts to that.
But what if we have, in our one GPS device (which does not use DST) and a few ordinary Linux servers (which do use DST), and all of them together should be used as time sources?
Well, the local Linux server which takes time from all the sources will work quite OK, regardless of the source using or not using DST :
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) LOCAL(0) 10 l 28 64 377 0.000 0.000 0.001
*does.not.use.DST .GPS. 1 u 674 1024 377 1.358 2.784 0.390
+does.use.DST 10.10.10.110 6 u 796 1024 377 3.918 -153.49 4.115
+doea.use.DST 10.10.10.11 5 u 858 1024 377 7.605 -122.96 128.946

Problem appears if we want NTP servers of higher strata (less good servers) to be primary time sources, and the GPS device (which has the lowest strata, that is, it is the best time source), should be treated as backup time source.
This is solved by using /etc/ntp.conf file, where our servers we mark as “prefered” :
server does.not.use.DST.goes.to.GPS
restrict does.not.use.DST.goes.to.GPS mask 255.255.255.255 nomodify notrap noquery
server does.use.DST.has.higher.strata prefer
restrict does.use.DST.has.higher.strata mask 255.255.255.255 nomodify notrap noquery
server does.use.DST.has.higher.strata prefer
restrict does.use.DST.has.higher.strata mask 255.255.255.255 nomodify notrap noquery

Relevant files :
/etc/ntp.conf – configuration file
/usr/share/zoneinfo/* – in these files (which are sorted by location) is info about DST!
/etc/timezone – I have here :
Europe/Belgrade
/etc/localtime – binary file
/var/log/messages – log file
/etc/ntp/keys
/etc/ntp/ntpservers – list of NTP servers to which our server is connected
/etc/ntp/step-tickers – list of NTP servers for sync during server boot
/etc/sysconfig/clock – time zone that is set for server :
ZONE=”Europe/Belgrade”
UTC=false – Coordinated Universal Time, Zulu, Greenich time or GTM. HW clock setup.
ARC=false – usage of “normal UNIX epoch” time

How to check NTP server :
#date – this is the environment variable value “TZ”
Thu Feb 7 08:56:30 CET 2013
#ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) LOCAL(0) 10 l 14 64 377 0.000 0.000 0.001
*10.10.10.11 .GPS. 1 u 86 128 377 0.214 -3.627 28.616
# ntpstat
synchronised to NTP server (10.10.10.11) at stratum 2
time correct to within 116 ms
polling server every 128 s
# pgrep ntpd – daje PID procesa
# ntpdc -c loopinfo
offset: -0.003627 s
frequency: 104.299 ppm
poll adjust: 7
watchdog timer: 445 s
# ntpq -crv
assID=0 status=0664 leap_none, sync_ntp, 6 events, event_peer/strat_chg,
version=”ntpd 4.2.0a@1.1190-r Thu Oct 5 04:11:32 EDT 2006 (1)”?,
processor=”i686″, system=”Linux/2.6.9-55.ELsmp”, leap=00, stratum=2,
precision=-20, rootdelay=1.344, rootdispersion=38.929, peer=44461,
refid=10.10.10.11,
reftime=d4bdfc04.1fd16766 Thu, Feb 7 2013 11:10:12.124, poll=10,
clock=0xd4bdfdf0.e7e6e653, state=4, offset=0.738, frequency=142.349,
noise=0.562, jitter=0.191, stability=12.189
# zdump -v /etc/localtime|grep 2013 – When DST does+/-60min in chosen locale
/etc/localtime Sun Mar 31 00:59:59 2013 UTC = Sun Mar 31 01:59:59 2013 CET isdst=0 gmtoff=3600
/etc/localtime Sun Mar 31 01:00:00 2013 UTC = Sun Mar 31 03:00:00 2013 CEST isdst=1 gmtoff=7200
/etc/localtime Sun Oct 27 00:59:59 2013 UTC = Sun Oct 27 02:59:59 2013 CEST isdst=1 gmtoff=7200
/etc/localtime Sun Oct 27 01:00:00 2013 UTC = Sun Oct 27 02:00:00 2013 CET isdst=0 gmtoff=3600

A good link.

This entry was posted in Linux and tagged , . Bookmark the permalink.

Comments are closed.