環境:Centos7.6centos
實驗主機:A:192.168.2.10服務器
B:192.168.2.11網絡
C:192.168.2.12(master)spa
這裏選擇C作時間服務器。rest
yum install ntp -y
#restrict default nomodify notrap nopeer noquery #將這條註釋
restrict 192.168.2.12 nomodify notrap nopeer noquery
restrict 192.168.2.0 mask 255.255.252.0 nomodify notrap #容許特定網段能同步時間code
server 127.127.1.0 若是網絡時間同步服務器不能夠用,就以本地時間爲標準想客戶端提供服務。 Fudge 127.127.1.0 stratum 10
#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 server
#將網絡時間服務地址註釋blog
配置解釋:
權限的設定主要以 restrict 這個參數來設定,主要的語法爲:
restrict IP地址 mask 子網掩碼 參數
其中 IP 能夠是IP地址,也能夠是 default ,default 就是指全部的IP
參數有如下幾個:
ignore :關閉全部的 NTP 聯機服務
nomodify:客戶端不能更改服務端的時間參數,可是客戶端能夠經過服務端進行網絡校時。
notrust :客戶端除非經過認證,不然該客戶端來源將被視爲不信任子網
noquery :不提供客戶端的時間查詢
#restrict default nomodify notrap nopeer noquery #註釋掉 restrict 192.168.2.10 nomodify notrap nopeer noquery restrict 192.168.2.0 mask 255.255.252.0 nomodify notrap #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
#註釋掉以上4條。
server 192.168.2.12 Fudge 192.168.2.12 stratum 10
systemctl start ntpd systemctl enable ntpd
啓動後5-10分鐘內自動進行同步。同步
1:C服務器:ast
2:A服務器:
3:B服務器