ntp服務restrict ntp伺服器配置問題

2021-10-13 05:01:16 字數 2895 閱讀 9093

1.配置/etc/ntp.conf,內容如下:

restrict default nomodify notrap

restrict 127.0.0.1   mask 255.0.0.0                      #開放本機的任何訪問

restrict 192.168.1.0 mask 255.255.255.0 nomodify

restrict 192.168.2.0 mask 255.255.255.0 nomodify

server 210.72.145.44 prefer

server 222.73.106.220 prefer

server 221.130.184.210 prefer

server 218.21.130.42

restrict 127.0.0.1

restrict 0.0.0.0 mask 0.0.0.0 nomodify #允許任何主機進行時間同步

server 127.127.1.0

fudge 127.127.1.0 stratum 10

driftfile /var/lib/ntp/drift (已存在)

broadcastdelay  0.008

keys            /etc/ntp/keys(已存在)

2.# ntpdate 222.73.106.220 提示資訊如下,表明該操作成功

looking for host 222.73.106.220 and service ntp

host found : 222.73.106.220

clock: old time 1970/01/01 - 00:07:44 gmt

clock: new time 2008/06/04 - 08:07:59 gmt

4 jun 08:07:59 ntpdate[45]: step time server 222.73.106.220 offset 1212566414.870733 sec

3。執行ntpd

#/bin/ntpd  -c   /etc/ntp.conf (已存在)

4。檢查ntpd是否起來,

採用ps命令可以看到:

75 root        856 s   /bin/ntpd -c /etc/ntp.conf

76 root        728 s   /bin/ntpd -c /etc/ntp.conf

說明是起來了的。

採用netstat -an(對應udp的state 為空是否表明是closed?為什麼?udp的123埠已經開啟了的啊???)

active internet connections (servers and established)

proto recv-q send-q local address           foreign address         state

tcp        0      0 0.0.0.0:80              0.0.0.0:*               listen

udp        0      0 192.168.1.46:123        0.0.0.0:*

udp        0      0 192.168.2.46:123        0.0.0.0:*

udp        0      0 127.0.0.1:123           0.0.0.0:*

udp        0      0 0.0.0.0:123             0.0.0.0:*

active unix domain sockets (servers and established)

proto refcnt flags       type       state         i-node path

最後用# ntpq -p

remote           refid      st t when poll reach   delay   offset  jitter

210.72.145.44   .acts.           1 u   62   16  377   64.540  11861.3 2375.66

222.73.106.220  2.0.244.117      3 u   69 1024   77   34.587  6672.13 4497.24

221.130.184.210 64.183.56.58     2 u   64 1024   77  134.977  6650.76 4501.00

218.21.130.42   204.152.184.72   2 u   70 1024   77  352.827  8002.26 3968.23

為什麼remote前都是空格,沒有「+」「*」?那說明沒有與上層伺服器連上,為什麼會這樣?

7。在客戶機上執行:ntpdate 192.168.1.88(上面配置的伺服器的ip)顯示:

no server suitable for synchronization found等待了五分鐘之後再次執行ntpdate 192.168.1.88仍然顯示no server suitable for synchronization found.

為何會這樣呢?是不是我配置的/etc/ntp.conf不對?

ntp服務是用udp的,udp不監聽的,所以stats沒listen,tcp才監聽的,

預設情況下,我們配置的ntp伺服器不會去時間源那裡同步時間,所以必須修改/etc/ntp/step-tickers檔案,加入我們的時間源,這樣每次通過/etc/init.d/ntpd 來啟動服務的時候就會自動更新時間了

#vi /etc/ntp/step-tickers

210.72.145.44

222.73.106.220

得保證上面的ip,你的機子能ping通

然後重啟下ntp服務,

配置ntp服務

客戶端 一 在 etc crontab 2 etc ntp.sh 每兩個小時校對一次時間 二 在 etc ntp.sh中新增 bin bash ntpdate 172.19.61.110 改變 etc ntp.sh的許可權 chmod 700 etc ntp.sh 三 etc init.d fcro...

NTP服務配置

寫於2013年秋,centos6.4 伺服器端 hadoop master1 sudo chkconfig ntpd on hadoop master sudo vi etc ntp.conf server 127.127.1.0 local clock fudge 127.127.1.0 stra...

NTP服務配置

ntp時間同步服務 安裝 1 yum y install ntp 2 service ntpd start 檢視同步詳情 ntpq p 引數 含義 remote 本地機器所連線的遠端ntp伺服器 refid 給遠端伺服器提供時間同步的伺服器 st遠端伺服器的層級別 1 16 避免 1t未知 when...