設定3台機器
選擇一台機器作為同步服務A,A與外網同步,B,C 同步A
配置A:sudo vi /etc/ntp.conf
删除預設配置:
#restrict default kod nomodify notrap nopeer noquery
#restrict -6 default kod nomodify notrap nopeer noquery
#restrict 127.0.0.1
#restrict -6 ::1
#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org
添加配置
允許那些機器與我同步
restrict 192.168.59.0 mask 255.255.255.0 nomodify notrap
配置A跟誰同步
server 202.112.10.36
配置本地同步
server 127.127.1.0
fudge 127.127.1.0 stratum 10
啟動ntp服務
sudo service ntpd start
檢視同步狀态:
ntpstat
配置B,C:
sudo vi /etc/ntp.conf
server 192.168.59.211
手動觸發同步:
sudo ntpdate 192.168.59.211
啟動ntp服務
sudo service ntpd start