Article Title: Configure NTP in Linux to set up a local time server. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Configure NTP to set up a local time server
NTP is a protocol used to synchronize time between the system and a precise time source. in Linux, we can use the Network Time Protocol to keep our system accurate.
Installation:
# Yum install ntp
Or find the ntp rpm package installation from the installation disk
When you only have one server that can be connected to the Internet, add
# Crontab-e
Add a row:
*/15 * ntpdate 210.72.145.44
210.72.145.44 is the address of the Chinese National Time Service Center server, so that the server can be synchronized with the National Time Service Center.
To set up a local time server, you only need to modify several simple configurations in the/etc/ntp. conf file. The following is the configuration I added:
# Add by Fengshihua
Server 210.72.145.44 prefer)
Server 218.21.130.42 (IP address of cn.pool.ntp.org)
Restrict 192.168.100.0 mask 255.255.255.0 nomodify (Intranet Communication allowed)
Restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap noquery notrust (shields other IP addresses from updating the time)
Others remain unchanged by default.
To enable the NTP service to automatically start during system boot, run:
# Chkconfig ntpd on
The command to start/disable/restart NTP is:
#/Etc/init. d/ntpd start
#/Etc/init. d/ntpd stop
#/Etc/init. d/ntpd restart
Write the synchronized time to CMOS.
Vi/etc/sysconfig/ntpd
SYNC_HWCLOCK = yes
Remember to restart the service every time you modify the configuration file to make the configuration take effect. You can run the following command to check whether the NTP service is started. You should be able to get a process ID:
# Pgrep ntpd
Run the following command to check the synchronization status of the Time Server:
# Ntpq-p
You can also use ntpstat to view some synchronization statuses. Use netstat-ntlup to view port usage!
It takes 5 to 10 minutes to update the client from the server after the client is installed!
Client settings:
# Crontab-e
Add a row:
*/15 * ntpdate Server IP address.