NTP: Configure a NTP server

Share this link

Install the NTP package:

# yum install -y ntpd

Then, several configuration options are possible:

1) Your new time server isn’t connected to any outside source of synchronized time.
Edit the /etc/ntp.conf file and comment out the following lines:

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

In the same file, enable the two following lines:

#server 127.127.1.0
#fudge 127.127.1.0 stratum 10

2) Your new time server will be connected to another time server of your choice.
Edit the /etc/ntp.conf file and comment out the following lines:

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

In the same file, add the following line with the name (or IP address) of your time server:

server timeserver

3) Your new time server will rely on default time servers.
In this case, you have nothing to do.

Add a rule to the firewall to allow NTP clients to connect

# iptables -I INPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT

Save the firewall configuration:

# service iptables save

Activate the NTP service at boot:

# chkconfig ntpd on

Start the NTP service:

# service ntpd start

Check that the NTP service is working properly:

# ntpq -p
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Leave a Reply

4 Comments on "NTP: Configure a NTP server"

Notify of
Sort by:   newest | oldest
limweipin
Member
limweipin

Hi, do I need to understand the iptables rules? Is iptables considered part of rhcsa?

smrbukhari
Member
smrbukhari

Hello CertDepot,

I have a couple of questions regarding this:

1) Can the TimeServer itself run chronyd (which is default RHEL7 service) and client have the ntpd running (do we need to disable chronyd on client to accomplish this)?

2) Now for the client configuration can we use “server timeserver prefer” directive in /etc/ntp.conf instead of commenting the default time server pools.

Also your tutorial shows the use of iptables which is replaced by firewalld, could you please help us clarify if we can just use firewall-cmd instead to add the ntp service….

Thanks in advance!

wpDiscuz

RHCSA7: Task of the day

Allowed time: 5 minutes.
Create a user account named "tony" with password “redhat” and belonging to a secondary group called “team”.

RHCE7: Task of the day

Allowed time: 8 minutes.
Set up an iScsi target based on a block backstore of 100MB called lv_iscsi with basic authentication, ext4 filesystem and standard firewall configuration.

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...