Table of Contents
Introduction
In this tutorial, How to install and configure NTP server in Centos. NTP- is a protocol that runs over port 123 UDP at the Transport Layer and allows computers to synchronize time over networks for an accurate time.
What is NTP?
NTP, or Network Time Protocol, is a networking protocol designed to synchronize the clocks of computers to a reference time source. It is used in various networked environments to ensure that all systems maintain accurate time, which is essential for tasks such as logging, security, and scheduled operations.
Why Use NTP on CentOS 7?
Using NTP on CentOS 7 helps you:
- Maintain accurate system time across all servers.
- Ensure the proper functioning of time-dependent applications.
- Avoid issues caused by time discrepancies.
Prerequisites
Before you begin, make sure you have the following:
- A CentOS 7 server with root or sudo access.
- A stable internet connection to access NTP servers.
Install and configure NTP
[vagrant@DevopsRoles ~]$ sudo yum -y install ntp
Configure NTP server
[vagrant@DevopsRoles ~]$ sudo vi /etc/ntp.conf
The content file “ntp.conf” as below
# line 18: add the network range your network
restrict 10.0.2.0 mask 255.255.255.0 nomodify notrap
# change servers for synchronization
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org
Start and startup ntp
[vagrant@DevopsRoles ~]$ sudo systemctl start ntpd
[vagrant@DevopsRoles ~]$ sudo systemctl enable ntpd
If Firewalld is running, allow NTP service. NTP uses 123/UDP.
[vagrant@DevopsRoles ~]$ sudo firewall-cmd --add-service=ntp --permanent
[vagrant@DevopsRoles ~]$ sudo firewall-cmd --reload
Check it works normally
[vagrant@DevopsRoles ~]$ ntpq -p
Conclusion
Installing and configuring NTP on CentOS 7 is essential for maintaining accurate system time, which is critical for various applications and services. By following this guide, you can ensure that your CentOS 7 server is properly synchronized with reliable time sources. Whether you are managing a single server or a complex network, NTP provides the accuracy and reliability needed for effective time management.
By carefully configuring NTP and addressing any potential issues, you can maintain a robust and accurate time synchronization setup, ensuring smooth and efficient operations across your network. I hope will this your helpful. Thank you for reading the DevopsRoles page!