Network Time Protocol (NTP) is a standard Internet Protocol used for Time synchronization on the Internet. NTP is used to synchronize computer time to certain time standards. The current Time standard is Universal Time Coordinated ). The primary developer of NTP is Professor David L. Mills from the University of Delaware.
What is the use of NTP for us? Simply put, when your computer time is not accurate, you can access the Internet and synchronize the time from the Internet.
For enterprises, if you have hundreds of thousands of computers that cannot directly connect to the Internet, time does not affect your business. If one computer is modified, it cannot be exhausted. At this time, the establishment of an NTP server will show its advantages.
Next we will learn how to build our own NTP time server.
I. Installation of the NTP server
If you want to learn it, you must install it first. Otherwise, how can you learn it?
The installation methods include:
1. RPM Installation
2. Install YUM
3. source code compilation and Installation
# Wget http://www.eecis.udel.edu /~ Ntp, ntp_spool, ntp4, ntp-4.2, ntp-4.2.6p4.tar.gz
# Tar zxvf ntp-4.2.6.tar.gz
# Cd ntp-4.2.6
#./Configure -- prefix =/usr/local/ntp -- enable-all-clocks -- enable-parse-clocks
# Make & make install
Ii. NTP configuration files and related commands
NTP configuration file:
The configuration file of/etc/ntp. conf NTP service.
1) permission settings are mainly set by the restrict parameter. The main syntax is:
Restrict IP Address mask subnet mask parameter
The IP address can be an IP address or a default IP address.
The following parameters are provided:
Ignore: Disable all NTP online services.
Nomodify: the client cannot change the time parameter of the server, but the client can perform network calibration on the server.
Notrust: the client source is considered as a untrusted subnet unless it passes authentication.
Noquery: no client Time query is provided.
2) use the server parameter to set the upper-level time server. Syntax:
Server IP address or domain name [prefer]
The IP address or domain name is the designated upper-level time Server. If prefer is added to the Server parameter, the NTP Server is calibrated based on the host time.
3) solves the transfer delay during NTP server Calibration Time
Use the driftfile parameter settings:
Driftfile file name
The time spent in contacting the upper-level time server is recorded in the file after the driftfile parameter.
Note: driftfile must be followed by a complete path file name, not a link file, and the file permission must be set to ntpd daemon for writing.
The/usr/share/zoneinfo/directory stores the setting files corresponding to each time zone.
/Etc/localtime local system time setting file.
/Etc/sysconfig/clock local time zone setting file.
When we modify the time ZONE in the ZONE option, the system will copy the corresponding time ZONE setting file to/usr/share/zoneinfo/and copy it to local/etc/localtime.
Related commands:
Date modification and display of date and time commands.
Hwclock writes the current system time to the CMOS command, which can only be used by the root user.
The ntpd NTP service daemon file must be started before it can provide the NTP service.
Ntpdate client Time Synchronization
3. Configure NTP
# Vi/etc/ntp. conf
#========= Permission control ==================
Restrict default kod nomodify notrap nopeer noquery reject IPV4 users
Restrict-6 default kod nomodify notrap nopeer noquery reject IPV6 users
Restrict 210.72.145.44 authorize the National Time Service Center Server to access local NTP
Restrict 133.100.11.8 authorize 133.100.11.8 to access local NTP
Restrict 127.0.0.1
Restrict-6: 1
Restrict 192.168.100.0 mask 255.255.255.0 nomodify subnet segment authorized access
#========= Source server ================
Server 210.72.145.44 prefer specifies the upper-level Update time server. Use this address first.
Server 133.100.11.8
#========== Difference Analysis ==================
Driftfile/var/lib/ntp/drift
Keys/etc/ntp/keys
# Service ntpd start RPM and YUM installation start Method
#/Usr/local/ntp/bin/ntpd-c/etc/ntp. conf-p/tmp/ntpd. pid source code compilation and installation start Method
After ntpd is started, the client will wait for several minutes to synchronize time with it. Otherwise, the error "no server suitable for synchronization found" will be displayed.
# Netstat-tlunp | grep ntp if port 123 is displayed, the ntp service is successfully started.
# Ntpstat check whether the ntp server communicates with the superior Server
# Ntpq-p check the communication between the local NTP server and the upper-level server
4. How to update the time on the client
On linux:
# Ntpdate 192.168.100.10
Manual update is too troublesome. We have to write a task plan for regular update.
# Vi/var/spool/cron/root
0 1 ***/usr/sbin/ntpdate 192.168.18.2
On windows:
This article is from the blog "the path to growth of Cui"