To configure an NTP (Network Time Protocol) client and server on CentOS or Red Hat Linux, you can follow these steps:
ntp
package using the package manager:sudo yum install ntp
/etc/ntp.conf
file and specify the NTP servers you want to use. You can use the server
directive to specify the NTP servers. For example:server 0.centos.pool.ntp.org server 1.centos.pool.ntp.org server 2.centos.pool.ntp.org server 3.centos.pool.ntp.org
ntpd
service:sudo systemctl start ntpd
ntpd
service to start automatically at boot:sudo systemctl enable ntpd
ntpd
service to make sure it's running:sudo systemctl status ntpd
ntpq -p
command to check the status of the NTP servers and make sure they are in sync.To configure the system as an NTP server, you can use the restrict
directive in the /etc/ntp.conf
file to specify which clients are allowed to connect to the NTP server. For example:
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
This will allow clients on the 192.168.1.0/24 network to connect to the NTP server, but they will not be able to modify the server's configuration or request time samples.
It's always a good idea to carefully review the documentation and use the appropriate options to configure your NTP client and server. This will help ensure that your system is able to accurately synchronize its clock with the NTP servers.