27 April 2010

How to: Setup a time server in linux

Configaration on NTP server (Linux machine)
cat > /etc/ntp.conf << EOF
server 0.pool.ntp.org
server 1.pool.ntp.org

server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 12

restrict default ignore
restrict 0.pool.ntp.org nomodify notrap noquery
restrict 1.pool.ntp.org nomodify notrap noquery
restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap
restrict 127.0.0.1

driftfile /var/lib/ntp/drift
EOF

yum install ntp
ntpdate -b pool.ntp.org

chkconfig --level 2345 ntpd on
service ntpd restart
wait for around 20 min for NTP server to initialize
check with "ntpq -p" the output should be like this:
make sure "*LOCAL(0)" is there ("*" is important here).
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
adelaide.ip4.ph .INIT. 16 u - 64 0 0.000 0.000 0.000
ox.eicat.ca .INIT. 16 u - 64 0 0.000 0.000 0.000
*LOCAL(0) .LOCL. 12 l 14 64 377 0.000 0.000 0.001

Configuration on NTP client (Windows machine)
net stop w32time && net start w32time
w32tm /config /manualpeerlist:192.168.0.105 /syncfromflags:manual /update
w32tm /resync /rediscover

Other configuration commands on NTP Client (windows machine)
w32tm /config /syncfromflags:domhier /update
w32tm /resync /rediscover

w32tm /stripchart /computer:192.168.0.105 /samples:3 /dataonly
w32tm /monitor /computers:192.168.0.105

Configuration on NTP client (Linux machine)
ntpdate 192.168.0.105

service ntpd stop
ntpdate 0.pool.ntp.org
Configure SNTP client on Nortel switch
(config)# clock time-zone IST +5 30
(config)# clock source sntp

(config)# sntp server primary address 192.168.0.105
(config)# sntp enable

(config)# show clock
Current SNTP time : 2010-04-27 20:30:26 GMT+05:30
Daylight saving time is DISABLED
Time zone is set to 'IST', offset from UTC is 05:30

Reference:
Introduction to NTP
Another blog - an help for NTP server configuration
http://www.tuxweb.net/howto/ntp/network_time_howto.html
http://www.meinberg.de/english/info/ntp.htm
http://support.ntp.org/bin/view/Servers/WebHome
The_NTP_Server
sntp.pl

No comments:

Post a Comment