Wednesday, December 10, 2014

Working with NTP (Network Time Protocol) Part 1

Installing and Configuring with the NTP

Hello Guys today i will tell you about the NTP protocol and how to play with NTP protocol and some fine tuning with it.so lets start.

To install the NTP on centos

To begin, log in as root

# yum –y install ntpd 

The default installation of NTP will use a public server that has access to the atomic clock, but in order to optimize the service we will need to make a few simple changes in order to streamline and optimize what time servers are used. To do this, we shall open the main configuration file with your favorite text editor like so:

# vi /etc/ntp.conf 
  
Scroll down and look for the following lines:
 
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.
html).

server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org

Replace the values shown with a list of preferred time servers like so:

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.
html).

server 0.uk.pool.ntp.org
server 1.uk.pool.ntp.org
server 2.uk.pool.ntp.org
server 3.uk.pool.ntp.org


Now find the following lines:
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodifynotrap
 
 Before starting our time service, we should add and confirm a network range in order that we can determine who can and who cannot receive time service-based requests.

To do this, uncomment the preceding line and replace the values to reflect your

network environment like so:
# Hosts on local network are less restricted.
Restrict XXX.XXX.XXX.XXX mask YYY.YYY.YYY.YYY nomodifynotrap
 
When complete, save and close the file before synchronizing your server by using the following command:

ntpdate NTP_SERVER_ADDRESS_HERE
For example, you can use ntpdate pool.ntp.org.
 
The initial synchronization request requires priming, so you may want to run and repeat this command several times before ensuring that the service will start during the boot process, by using the following command:

# chkconfig ntpd on
 
When finished, you can start the NTP service like so:
 
# service ntpd start
 
You should reboot to ensure that the relevant changes take effect:
 
# reboot
 
Well done, you have now installed and configured the NTP service. The overall process of time synchronization will take some time to complete, but you will be able to use the standard NTP query program (ntpq) in order to review a list of known peers as and a summary of their current state. To do this, return to your
console and type:

# ntpq–p
 

All daemons are prone to the environmental conditions found on your network, and the NTP service is not an exception. Periodic packet breaks can be disruptive, but even if you have not
experienced this yet, it may be advantageous to explore a solution that will make your NTP service far more persistent when probing the third-party servers. Known as the iburst option, this feature is designed to tell the NTP service to issue a burst
of eight packets to the remote server instead of one in order to offer an improved approach to the time synchronization process. Implementing this method is very simple and to begin,
simply return to your console and open the main configuration file in your favorite text editor
like so:

# vi /etc/ntp.conf

Scroll down the file and locate your time servers. Now simply append your time servers with a whitespace followed by the term iburst. For example, your new configuration file will look
like this:

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.
html).
server 0.uk.pool.ntp.org iburst
server 1.uk.pool.ntp.org iburst
server 2.uk.pool.ntp.org iburst
server 3.uk.pool.ntp.org iburst

to sync the clock with the hardware clock we need to sync it by using the following command 
 
# hwclock–systohc

and need to reboot using reboot command  

# hwclock–show

 
 



No comments:

Post a Comment