Configure basic ntp server and client

From Notes_Wiki
Revision as of 11:02, 14 July 2022 by Saurabh (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Home > CentOS > CentOS 6.x > Time server configuration > Configure basic ntp server and client

Configure ntp server

To configure basic ntp server on centos use following steps:

  1. yum -y install ntp ntpdate ntp-doc
  2. edit /etc/sysconfig/ntpd and change to
    OPTIONS="-p /var/run/ntpd.pid -g"
  3. edit /etc/ntp.conf and add one line for each local network as follows:
    restrict 192.168.2.0 mask 255.255.255.0 nomodify notrap
  4. service ntpd restart
  5. ntpq
    1. pe
    2. as
      If peers show strata (st) greater than 3 or 4 and associations show reach as no then there must be a firewall issue Please refer to http://superuser.com/questions/141772/what-are-the-iptables-rules-to-permit-ntp for firewall From firewall perspective on server allow
      iptables -A INPUT -p udp --dport 123 -j ACCEPT
      iptables -A OUTPUT -p udp --sport 123 -j ACCEPT


Note that setting up ntp server or client on openVZ container will not work. Both ntp server and client must be setup only on base machines


Configure ntp client

  1. yum -y install ntp ntpdate ntp-doc
  2. edit /etc/sysconfig/ntpd and change to
    OPTIONS="-p /var/run/ntpd.pid -g"
  3. edit /etc/ntp.conf and comment all server lines. Finally add one server line to point to local ntp server
  4. service ntpd restart
  5. ntpq
    1. pe
    2. as
      If peers show strata (st) greater than 3 or 4 and associations show reach as no then there must be a firewall issue. For firewall refer to http://superuser.com/questions/141772/what-are-the-iptables-rules-to-permit-ntp From firewall perspective on server allow
      iptables -A OUTPUT -p udp --dport 123 -j ACCEPT
      iptables -A INPUT -p udp --sport 123 -j ACCEPT

To debug connection to local ntp server you can use: "ntpdate -db <ntp-server>" and see what is going on.


Home > CentOS > CentOS 6.x > Time server configuration > Configure basic ntp server and client