1. First install NTP
[email protected]/]# Yum install ntp-y
2. Modify the NTP configuration file to add the network location of the NTP server/etc/ntp.conf
# For more information on this file, see the Man pages# ntp.conf (5), NTP_ACC (5), Ntp_auth (5), Ntp_clock (5), Ntp_misc (5) , Ntp_mon (5). driftfile/var/lib/ntp/drift# Permit time synchronization with our time source, but do not# Permit the source To query or modify the service in this system.restrict default nomodify notrap nopeer noquery# Permit All Access over the Loopback interface. This could# is tightened as well, but to does so would effect some of# the administrative functions.restrict 127.0.0.1restri CT:: # Hosts on local network is less restricted. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap# with public se RVers from the Pool.ntp.org project. Please consider joining the pool (http://www.pool.ntp.org/join.html). Server 192.168.1.1 iburst #目标服务器网络位置 #server 1.c Entos.pool.ntp.org Iburst #一下三个是CentOS官方的NTP服务器, we commented out #server 2.centos.pool.ntp.org iburst#server 3. centos.pool.ntp.org iburst#broadcast 192.168.1.255 AutoKey # broadcast Server#broadcastclient # broadcast Client#broadcast 224.0.1.1 autokey # multicast Server#multicastclient 224.0.1.1 # multicast Client#manycastserver 239.255.254.254 # manycast server#manycastclient 239.255.254.254 Auto Key # Manycast client# Enable Public key cryptography. #cryptoincludefile/etc/ntp/crypto/pw# key file containing the keys and key identifiers used when operating# with symmetric key cryptography.keys/etc/ntp/keys# specify the key identifiers W Hich is trusted. #trustedkey 4 8 42# Specify the key identifier to use with the NTPDC utility. #requestkey 8# Specify the K EY identifier to use with the NTPQ utility. #controlkey 8# Enable Writing of Statistics records. #statistics Clockstats Cryp Tostats loopstats peerstats# Disable the monitoring facility to prevent amplification attacks using ntpdc# monlist command When default restrict does not include the Noquery flag. see# cve-2013-5211 For more details.# note:monitoring is not being disabled with the Limited Restriction flag.disable Monitor
Save exit
3. Start the service and set the turn on self-starter
[Email protected]/]# systemctl start Ntpd.service #启动服务
[Email protected]/]# Systemctl enable Ntpd.service #设置为开机启动
4. View the running status
[Email protected]/]# systemctl status Ntpd.service
Ntpd.service-network Time Service
Loaded:loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset:disabled)
Active:active (running) since two 2016-10-11 13:34:11 CST; 8min ago
Main pid:6497 (NTPD)
CGroup:/system.slice/ntpd.servicess
└─6497/usr/sbin/ntpd-u ntp:ntp-g
October 13:34:11 localhost.localdomain ntpd[6497]: Listen and drop on 1 V6wildcard:: UDP 123
October 13:34:11 localhost.localdomain ntpd[6497]: Listen normally on 2 lo 127.0.0.1 UDP 123
October 13:34:11 localhost.localdomain ntpd[6497]: Listen normally on 3 eno16777736 192.168.100.100 UDP 123
Installation and configuration of Linux time synchronization NTP service