Centos 搭建本地NTP服務器。


  環境:Centos7.6

  實驗主機:A:192.168.2.10

       B:192.168.2.11

       C:192.168.2.12(master)

  這里選擇C做時間服務器。

一:安裝NTP服務。

yum install ntp -y

二:修改配置文件。

1:C服務器添加如下配置

#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  #允許特定網段能同步時間


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 

  #將網絡時間服務地址注釋

配置解釋:
權限的設定主要以 restrict 這個參數來設定,主要的語法為:
restrict IP地址 mask 子網掩碼 參數
其中 IP 可以是IP地址,也可以是 default ,default 就是指所有的IP
參數有以下幾個:
ignore :關閉所有的 NTP 聯機服務
nomodify:客戶端不能更改服務端的時間參數,但是客戶端可以通過服務端進行網絡校時。
notrust :客戶端除非通過認證,否則該客戶端來源將被視為不信任子網
noquery :不提供客戶端的時間查詢

2:A和B服務器添加如下配置。(注意對應IP)

#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

 

三:啟動和自啟動NTP服務

systemctl start ntpd
systemctl enable ntpd

  啟動后5-10分鍾內自動進行同步。

四:查看服務狀態。

  1:C服務器:

  

  2:A服務器:

  

  3:B服務器

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM