I. Introduction:
Network Time Protocol (NTP) is used to synchronize time between the distributed time server and the client. NTP transmits data based on UDP packets. The UDP port number is 123.
NTP is used to synchronize the clock of all devices in the network, so that the clock of all devices in the network is consistent, so that the devices can provide multiple applications based on the unified time.
If a time error occurs, the server will be down. Therefore, the local system running NTP can accept synchronization from other clock sources and synchronize other clocks as the clock source, and can be synchronized with other devices.
2. Set up a time server (server)
1. Build the environment
Environment: CentOS6.4
Server192.168.126.1
Client192.168.126.2
2. Install NTP yum-yinstall ntp
3. modify the configuration file and add this line of vim/etc/ntp. conf.
Restrict 192.168.126.0255.255.0 nomodify notrap
4. Find the two lines and remove the comments vi/etc/ntp. conf.
# Server127.127.1.0
# Fudge127.127.1.0stratum 10
5. Start the service
Chkconfig -- level 345 ntpon
6. Start the service
/Etc/init. d/ntpd start
7. The firewall must enable port 123 or disable the firewall.
-A input-m state -- state NEW-m tcp-p tcp -- dport 123-jACCEPT
Iii. Client
1. Run the following command to synchronize time with the server:
Manual execution or crontab execution
Manual: ntpdate 192.168.126.1
Crontab-e
0 21 **** ntpdate 192.168.126.1>/root/ntpdate. log 2> & 1
2. View synchronization status ntpq-p
3. enable or disable the firewall on port 123.
-A input-m state -- state NEW-m tcp-p tcp -- dport 123-jACCEPT
CentOS NTP server installation and configuration
NTP servers in Linux
NTP client configurations for multiple operating systems