How to Setup NTP Server in CentOS?

NTP enables the automatically sync your system time with a remote server. With the help of NTP server, you can keep your system time up to date as per the main server. Your system clock time may drift slightly from the time you have set on clock. Up to date time on the system helps you to find the logs from the time and date you want to check.

  1. Following are the steps to install and configure NTP Server on Centos.

    # sudo yum install ntp
    
  2. Once the installation is completed, you can run the below command to run service on boot time.

    # service enable ntpd
    
  3. You can start/stop or restart the NTP Service by giving the below command.

    # service ntpd start
    # service ntpd stop
    # service ntpd restart
  4. After installation of NTP Server, you can click on this link (https://www.pool.ntp.org/en/) for the NTP Public Pool time server. Select your continent area where your server is located and find your country on the NTP server list.

  5. Now, edit the configuration file /etc/ntp.conf of NTP daemon and comment the default public server from pool.ntp.org and change the list provided by your country.

    From
    # sever 0.centos.pool.ntp.org iburst
    # sever 1.centos.pool.ntp.org iburst
    Change it to
    sever 0.ro.pool.ntp.org iburst
    sever 1.ro.pool.ntp.org iburst
  6. If you are looking to allow customers from your networks to sync time with this server. You should make the changes in the NTP configuration like as given below:

    restrict 192.168.1.0 netmask 255.255.255.0 nomodify notrap
    
  7. As per nomodify notrap, your clients are not allowed to configure the server. You can add a rule in the firewall if it is enabled on your server.

    # firewall-cmd –add-service=ntp –permanent
    
  8. Reload the firewall.

    # firewall-cmd –reload
  9. Start an enalbe NTP server

    # systemctl start ntpd
    # systemctl enable ntpd
  10. Check the NTP status that it is running fine.

    # systemctl status ntpd
  11. You can verify the time sync by executing the below command.

    # ntpq -p
    # date –R
  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to use chmod to change file permission?

In this article, we will describe how to use the chmod command to modify file permission in Linux...

How to install Virtualmin/Webmin control panel in CentOS 7?

Please refer to the following steps to install Virtualmin/Webmin on Centos 7.x Let us update...

How to add IP address in Ubuntu using command?

Sometimes you may require to add the IP Address manually in ubuntu network Interface. Following...

How to configure Exim outgoing IP address from WHM?

By Default, All the outgoing emails from the Exim will be sent from the server’s primary IPv4...

How to check Various cPanel logs like WHM, Apache, MySQL, Email, Error etc?

You can use cPanel to access your Linux hosting account with GUI. It is relatively easier to work...