Tuesday, April 16, 2013

How to configure NTP Server and Client on CentOS

Introduction

NTP is widely used to synchronize a computer to Internet time servers or other sources, such as a radio or satellite receiver or telephone modem service. It can also be used as a server for dependent clients. It provides accuracies typically less than a millisecond on LANs and up to a few milliseconds on WANs. Typical NTP configurations utilize multiple redundant servers and diverse network paths in order to achieve high accuracy and reliability.

Configure NTP Server

  1. yum install ntp (and type 'y' when show up two questions);
  2. vi /etc/ntp.conf
  3. Add the next statement for accept requests from another servers (DNS server, LDAP server, etc.) on your LAN:
    restrict 10.50.0.0 mask 255.255.255.0 nomodify nopeer noquery
  4. Add the next statement for public servers NTP synchronize with server's internal clock on your LAN:
    server 0.europe.pool.ntp.org
    server 1.europe.pool.ntp.org
    server 2.europe.pool.ntp.org
    server 3.europe.pool.ntp.org
  5. This command allow to set current time from indicated NTP server:
    ntpdate pool.ntp.org
  6. The same server can be defined on configuration file:
    vi /etc/ntp/step-tickers
    pool.ntp.org
  7. service ntpd start
  8. Make sure the ntpd is active from beginning Linux boot;
    chkconfig ntpd on
  9. Checking synchronization status of service NTP.
    nptq -pn
    tail -f /var/log/messages

Configure NTP Client

  1. This file allows to set server NTP to use for initial adjust clock during starting of ntpd:
    vi /etc/ntp/step-tickers
    10.50.0.254
  2. On the file /etc/ntp.conf, all you need is add server NTP's IP address to use:
    vi /etc/ntp.conf
    server 10.50.0.254
  3. Checking synchronization status of service NTP.
    nptq -pn
    tail -f /var/log/messages
    It can take long to see message of success. When I was configuring, it took about 1 hour.

Conclusion

This protocol allows to keep operating system's clock synchronized with high accurate, running at information of synchronism got from another NTP servers.

Although the configuration is relatively simple, NTP performances a very important role. The possibility to make sure that clocks from many servers are kept with right time is relevant and it is a important factor to correct of many applications. The correction of local time in operating system allows also ensure that logs recorded in operating system have correct time and that is important when I use logs to diagnostic problems of some services.

3 comments:

  1. the command "nptq -pn" needs to be replaced by "ntpq -pn"

    ReplyDelete
  2. Thank you for sharing. The goal of Reliability Software should be to stop the insanity that frustrates and bring detailed, useful information to those who must make a decision in a quick, intuitive manner.

    ReplyDelete
  3. What's up it's me, I am also visiting this web site daily, this website is in fact good and the visitors are in fact
    sharing pleasant thoughts.

    my homepage ... http://sitab.pl

    ReplyDelete