How to Setup NTP Server on CentOS/RHEL 7/6/5

Network Time Protocol (NTP) is used to synchronize system clocks of different hosts over network. Most companies will have a local NTP server that they keep in sync with an external timing source and then they have all of their internal servers sync their time with that machine. In this setup we will configure Linux system as NTP sever.


Install the NTP Packages

NTP server package is provided by CentOS/RHEL default repositories and can be installed using yum command.

# yum install ntp

Configure NTP Server

If you have lots of server in the environment and this we will use NTP servers to synchronize time by the ISP or the Public time located at We suggest to use any near by servers also. You can find nearby servers at NTP Public Pool Time Servers (

# vim /etc/ntp.conf
server iburst
server iburst
server iburst
server iburst

NTP Server

Allow LAN Systems

Now, you need to allow clients from your networks to synchronize time with this server. To do it add following entry in configuration file

# vim /etc/ntp.conf
restrict mask nomodify notrap

Enable NTP Log

In case there are problems with your NTP daemon add a log file statement which will record all NTP server issues. Add the following content as below.

# vim /etc/ntp.conf
logfile /var/log/ntp.log


Add Firewall Rules

NTP server listen on UDP port 123. If you are using iptables of server then run the following command.

# firewall-cmd --add-service=ntp --permanent
# firewall-cmd --reload

CentOS/RHEL 6/5

# iptables -A INPUT -s -p udp --dport 123 -j ACCEPT
# iptables -A INPUT -p udp --dport 123 -j DROP

Restart NTP Server

After all NTP configuration, Let’s restart NTP server using following commands.


# systemctl start ntpd
# systemctl enable ntpd

CentOS/RHEL 6/5

# service ntpd start
# chkconfig ntpd on

Verify Configuration

You can verify the configuration using below command.

# ntpq -p
# date -R

Enjoy it!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.