Difference between revisions of "Configure basic ntp server and client"

From Notes_Wiki
m
m
 
Line 1: Line 1:
<yambe:breadcrumb>Ntp_server_configuration|Ntp server configuration</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Time server configuration]] > [[Configure basic ntp server and client]]
=Configure basic ntp server and client=


==Configure ntp server==
==Configure ntp server==
Line 49: Line 48:




<yambe:breadcrumb>Ntp_server_configuration|Ntp server configuration</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Time server configuration]] > [[Configure basic ntp server and client]]

Latest revision as of 11:02, 14 July 2022

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