Shashikant shah

Monday, 26 September 2016

NTP Server configure on Centos 6

NTP Server on Centos 6

1.       Host Details :-
NTP server :- ntp.momagic.com  192.168.1.10
NTP client :- client.example.com 192.168.1.11

Note :- Both machine add ip and hostname in  /etc/hosts file :-

# vim /etc/hosts
192.168.1.10  ntp.momagic.com  
192.168.1.11  client.example.com

Note :- both machine Iptable and Selinux service is disabled.

2.       Install NTP in both machine :-
# yum install ntp

3.       NTP Server side  :-
# cp –rf  /etc/ntp.conf   /etc/ntp.conf.bkp
# vim  /etc/ntp.conf
i)        The drift file is used to store the frequency offset between the system clock running at its nominal frequency.
driftfile /var/lib/ntp/drif
restrict  default  kod  nomodify  notrap  nopeer  noquery
restrict -6 default  kod  nomodify  notrap  nopeer  noquery

§  noquery :- prevents dumping status data from ntpd.
§  notrap  :- prevents control message trap service.
§  nomodify :- prevents all ntpq queries that attempts to modify the server.
§  nopeer :- prevents all packets that attempts to establish a peer association.
§  Kod :-  Kiss-o-death packet is to be sent to reduce unwanted queries
§  The value -6 in the second line allows forces the DNS resolution to the IPV6 address resolution.
ii)       If the localhost needs to have the full access to query or modify.
restrict 127.0.0.1
restrict -6 ::1
iii)     Only allow machines on your own network to synchronize with your NTP server.
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
iv)     NTP Server synchronize below server with internet.
server 0.asia.pool.ntp.org iburst
server 1.asia.pool.ntp.org iburst
server 2.asia.pool.ntp.org iburst
server 3.asia.pool.ntp.org iburst
v)      if the NTP server is disconnected from the internet, NTP server provides time from its local system clock.
server 127.127.1.0
fudge  127.127.1.0 stratum 10
server 192.168.1.10 iburst

includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
logfile /var/log/ntp.log

#  service ntpd start
# chkconfig ntpd on
# ntpq -p 
4.       Client side :-
# vim  /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server 192.168.1.10 prefer
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
logfile /var/log/ntp.log 
# service ntpd  start
# chkconfig ntpd on
# ntpq –p
# ntpdate  –u  192.168.1.10
5.       Add Cron job :-
*/5 * * * * /usr/sbin/ntpdate -u 192.168.1.10