CentOS / Red Hat Configure an NTP Client And Server
To configure an NTP client and server on CentOS or Red Hat Linux, follow these steps:
- Install the NTP package on the server:
sudo yum install ntp - Edit the NTP configuration file
/etc/ntp.conf:sudo nano /etc/ntp.conf - In the
serversection, add one or more NTP servers that the client should synchronize with. For example, to synchronize with the NTP pool servers, add the following lines:server 0.centos.pool.ntp.orgrnserver 1.centos.pool.ntp.orgrnserver 2.centos.pool.ntp.orgrnserver 3.centos.pool.ntp.orgYou can also specify your own NTP server, if you have one.
- Save and exit the file.
- Start the NTP service:
sudo systemctl start ntpd - Enable the NTP service to start automatically at boot time:
sudo systemctl enable ntpd - To verify that the client is synchronizing with the NTP server, use the
ntpqcommand:ntpq -pThis will show a list of the NTP servers that the client is synchronizing with, along with their status and the current offset.
- Edit the NTP configuration file
/etc/ntp.conf:sudo nano /etc/ntp.conf - In the
serversection, add theiburstoption to the server line to improve synchronization speed:server 127.127.1.0 iburstThis specifies that the local clock should be used as a reference clock.
- Save and exit the file.
- Start the NTP service:
sudo systemctl start ntpd - Enable the NTP service to start automatically at boot time:
sudo systemctl enable ntpd
