ntp 簡易操作實現時間同步
阿新 • • 發佈:2020-12-23
服務端操作
1.yum -y install ntp ntpdate #安裝ntp
2.vim /etc/ntp.conf #修改配置檔案 直接複製上去 ip和網段換成自己的
ftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 192.168.181.182
restrict -6 ::1
#允許內網其他機器同步時間
restrict 192.168.181.0 mask 255.255.255.0 nomodify notr
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
#定義使用的上游 ntp伺服器,將原來的註釋
server ntp1.aliyun.com
server time1.aliyun.com
#允許上層時間伺服器主動修改本機時間
restrict time1.aliyun.com nomodify notrap noquery
restrict ntp1.aliyun.com nomodify notrap noquery
#外部時間伺服器不可用時,以本地時間作為時間服務
server 127.127.1.0
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
3.systemctl start ntpd #啟動ntp
4.ntpq -p #測試
客戶端測試
1.yum -y install ntp ntpdate #安裝ntp
2.date -s 1111 #隨意修改時間
3.ntpdate 192.168.181.182 #同步測試