Tricks and Tips about Systems/Network

October 15, 2010

How do I setup Time server On Centos (ntp server)

Filed under: admins,CentOS — Liju Mathew @ 10:17 pm

Some critical applications ( odesk) requires system time to be updated with the server time in order to work certain features. Also you will get some application will not able to install if the local time is out dated or older. Damaged BIOS batter also cause this to happen.

So I decided to install a Network Time server in LAN. Also I have added a cron or scheduler set on each workstation to communicate with this server and re-build our OS disk images.

install ntp using yum.

# yum install ntp*
# Modify the following lines

    restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap

; changed to my network
added the following lines.

    server 192.168.0.1
    server 127.127.1.0
    fudge 127.127.1.0 stratum 10

Or you may replace the ” /etc/ntp.conf” with following entries, This is my ntp config. file
[root@rc-025 ~]# cat /etc/ntp.conf | sed '/ *#/d; /^ *$/d'

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
server 192.168.0.1
server 127.127.1.0
fudge 127.127.1.0 stratum 10

Restart the ntpd service,

[root@rc-025 ~]# service ntpd restart
Shutting down ntpd: [ OK ]
Starting ntpd: [ OK ]

Verify the status,
[root@rc-025 ~]# netstat -nlp | grep ":123"
udp 0 0 172.16.11.1:123 0.0.0.0:* 21156/ntpd
udp 0 0 172.16.23.1:123 0.0.0.0:* 21156/ntpd
udp 0 0 192.168.0.1:123 0.0.0.0:* 21156/ntpd
udp 0 0 192.168.0.41:123 0.0.0.0:* 21156/ntpd
udp 0 0 192.168.0.25:123 0.0.0.0:* 21156/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 21156/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 21156/ntpd
udp 0 0 fe80::21c:c0ff:fea3:123 :::* 21156/ntpd
udp 0 0 fe80::250:56ff:fec0:1:123 :::* 21156/ntpd
udp 0 0 fe80::250:56ff:fec0:8:123 :::* 21156/ntpd
udp 0 0 ::1:123 :::* 21156/ntpd
udp 0 0 :::123 :::* 21156/ntpd
[root@rc-025 ~]#

Pls note that ntp is using UDP protocol. So that you can test it using telcommand.

How to verify the NTP server is working, Go to client desktop,
The following commands shows it’s working,

[root@rc-090 SVN-Archive]# date -s "16:55:30 Jun 09, 1981"
Tue Jun 9 16:55:30 IST 1981
[root@rc-090 SVN-Archive]# date
Tue Jun 9 16:55:32 IST 1981
[root@rc-090 SVN-Archive]# ntpdate -u 192.168.0.1
15 Oct 14:58:31 ntpdate[18516]: step time server 192.168.0.1 offset 926200973.366843 sec
[root@rc-090 SVN-Archeive]# date
Fri Oct 15 14:58:33 IST 2010

-njoy

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.