What is NTP (Network Time Protocol)-
NTP is the most common method to synchronize the software clock of a GNU/Linux system with internet time servers. It is designed to mitigate the effects of variable network latency and can usually maintain time to within tens of milliseconds over the public Internet. The accuracy on local area networks is even better, up to one millisecond.
NTP servers communicate over port 123 UDP and unlike most UDP protocols the source port is NOT a high port, but uses 123 as well.
Configure NTP Server-
Server side ..
------------------
Step 1:-
# yum install ntp -y (Install NTP Package)
Step 2:-
Open configuration file and edit,
# vim /etc/ntp.conf
server 172.24.0.1
server 127.127.1.0
fudge 127.127.1.0 stratum 10
driftfile /var/lib/htp/drift
:wq
Note-
Where,
server- The server command is used to configure a reference clock, where the
address argument in that command is the clock address.
fudge - The fudge command is used to provide additional information for individ-
ual clock drivers and normally follows immediately after the server com-mand.
driftfile- This command specifies the complete path and name of the file
used to record the frequency of the local clock oscillator.
Step 3:-
# system-config-date
-->RHEL6 -->> date and time
--> Check d button -->> Synchronize date and
time over the Network
NTP SEVER --> IP of Server( 172.24.0.1)
-->>Advanced Options
-->>Use Local Time Source
--->>OK
Step 4:-
#server ntpd restart ; chkconfig ntpd on
Client Side :--
-----------------
Step 1:-
# system-config-date
-->RHEL6 -->> date and time
--> Check d button -->> Synchronize date and
time over the Network
NTP SEVER --> IP of Server( 172.24.0.1)
-->>Advanced Options
-->> Speed up initial synchronize
--->>OK
Step 2:-
# Server ntpd restart; chkconfig ntpd on
Step 3:-
If u can't have DNS
# vim /etc/hosts
ip of server Server Host Name
172.24.0.1 server1.example.com server1
:wq
If u have DNS
# vim /etc/sysconfig/ntpd
OPTIONS = "-4 -6 (defaults options) "
:wq
Note: -4 for ipv4 and -6 for ipv6
# Server ntpd restart; chkconfig ntpd on
NTP server troubleshooting
1.How to Check the NTPD service is running or not
#pgrep ntpd
or
#ps -eaf |grep -i ntpd
2.If there is no NTP service is running then start the service
Start NTP Server and check /var/log/messages
#/sbin/chkconfig --list ntpd
#/sbin/chkconfig ntpd on
#systemctl start ntpd.service
or
#/etc/init.d/ntp start
or
#/etc/init.d/xntpd start
#ntpdate -u "NTP server IP address"
3.Check the NTP is synced or not
#ntpq -p
#ntpstat
//show the network time synchronization status
4.Check the NTP config file is the server IP entered correctly.
#more /etc/ntp.conf
_____________________________________________________________________________________________
NTP is the most common method to synchronize the software clock of a GNU/Linux system with internet time servers. It is designed to mitigate the effects of variable network latency and can usually maintain time to within tens of milliseconds over the public Internet. The accuracy on local area networks is even better, up to one millisecond.
NTP servers communicate over port 123 UDP and unlike most UDP protocols the source port is NOT a high port, but uses 123 as well.
Configure NTP Server-
Server side ..
------------------
Step 1:-
# yum install ntp -y (Install NTP Package)
Step 2:-
Open configuration file and edit,
# vim /etc/ntp.conf
server 172.24.0.1
server 127.127.1.0
fudge 127.127.1.0 stratum 10
driftfile /var/lib/htp/drift
:wq
Note-
Where,
server- The server command is used to configure a reference clock, where the
address argument in that command is the clock address.
fudge - The fudge command is used to provide additional information for individ-
ual clock drivers and normally follows immediately after the server com-mand.
driftfile- This command specifies the complete path and name of the file
used to record the frequency of the local clock oscillator.
Step 3:-
# system-config-date
-->RHEL6 -->> date and time
--> Check d button -->> Synchronize date and
time over the Network
NTP SEVER --> IP of Server( 172.24.0.1)
-->>Advanced Options
-->>Use Local Time Source
--->>OK
Step 4:-
#server ntpd restart ; chkconfig ntpd on
Client Side :--
-----------------
Step 1:-
# system-config-date
-->RHEL6 -->> date and time
--> Check d button -->> Synchronize date and
time over the Network
NTP SEVER --> IP of Server( 172.24.0.1)
-->>Advanced Options
-->> Speed up initial synchronize
--->>OK
Step 2:-
# Server ntpd restart; chkconfig ntpd on
Step 3:-
If u can't have DNS
# vim /etc/hosts
ip of server Server Host Name
172.24.0.1 server1.example.com server1
:wq
If u have DNS
# vim /etc/sysconfig/ntpd
OPTIONS = "-4 -6 (defaults options) "
:wq
Note: -4 for ipv4 and -6 for ipv6
# Server ntpd restart; chkconfig ntpd on
NTP server troubleshooting
1.How to Check the NTPD service is running or not
#pgrep ntpd
or
#ps -eaf |grep -i ntpd
2.If there is no NTP service is running then start the service
Start NTP Server and check /var/log/messages
#/sbin/chkconfig --list ntpd
#/sbin/chkconfig ntpd on
#systemctl start ntpd.service
or
#/etc/init.d/ntp start
or
#/etc/init.d/xntpd start
#ntpdate -u "NTP server IP address"
3.Check the NTP is synced or not
#ntpq -p
#ntpstat
//show the network time synchronization status
4.Check the NTP config file is the server IP entered correctly.
#more /etc/ntp.conf
_____________________________________________________________________________________________