Windows NTP
1 windows 平臺校時協定:
windows 2000 : SNTP
windows xp sp2 以前 : SNTP
windows xp sp2 以後(含sp2) : NTP(v3)
windows 2003,vista,2008 : NTP(v3)
參考:Table: Network environment applicable for this application note.
NTP Server 所提供的服務中,
Root Dispersion 這個值會影響Cisco 設備是否接受該 NTP Server 所提供的校時資訊!!
1 windows 平臺校時協定:
windows 2000 : SNTP
windows xp sp2 以前 : SNTP
windows xp sp2 以後(含sp2) : NTP(v3)
windows 2003,vista,2008 : NTP(v3)
參考:Table: Network environment applicable for this application note.
NTP Server 所提供的服務中,
Root Dispersion 這個值會影響Cisco 設備是否接受該 NTP Server 所提供的校時資訊!!
Windows Server 2008 (或 2003) 主機本身若未設定 Window Time 本身對外校時, 則 Root Dispersion 的值為10(秒,預設值),
Cisco PIX 515R 無法接受這麼大的 Root Dispersion 值,當然就不會校時!
參考:http://www.cisco.com/en/US/tech/tk648/tk362/technologies_tech_note09186a0080a23d02.shtml#wtm
Cisco PIX 515R 無法接受這麼大的 Root Dispersion 值,當然就不會校時!
參考:http://www.cisco.com/en/US/tech/tk648/tk362/technologies_tech_note09186a0080a23d02.shtml#wtm
其他 tftpd 和 linux 的 ntpd ,其 Root Dispersion 都在 1 秒以下,
Cisco PIX 515R 都可以接受並且校時!
Cisco PIX 515R 都可以接受並且校時!
只要 Windows Server 2008 (或 2003) 的 Window Time 的 Root Dispersion 值變成1 秒以下,
就可以讓 Cisco PIX 515R 成功的校時!
就可以讓 Cisco PIX 515R 成功的校時!
作法1:
在校時主機上執行 w32tm /config
/LocalClockDispersion:0 來手動更改 Dispersion 值!
這種方法只適用於校時主機本身的時間未透過 Windows Time 來對外校時,
在校時主機上執行 w32tm /config
/LocalClockDispersion:0 來手動更改 Dispersion 值!
這種方法只適用於校時主機本身的時間未透過 Windows Time 來對外校時,
作法2:
設定校時主機本身的時間透過 Windows Time 來對外校時,
可直接用 net time /setsntp:[外部校時主機] 來進行設定,
唯這種方式取的 Root Dispersion 值在完成第一次的定並校時後
可能需要幾十分鐘或幾小時時間才會慢慢變成 1 秒以下!
(這表示在這段時間之前 Cisco PIX 515R 無法使用 Windows Time 的服務來校時)
設定校時主機本身的時間透過 Windows Time 來對外校時,
可直接用 net time /setsntp:[外部校時主機] 來進行設定,
唯這種方式取的 Root Dispersion 值在完成第一次的定並校時後
可能需要幾十分鐘或幾小時時間才會慢慢變成 1 秒以下!
(這表示在這段時間之前 Cisco PIX 515R 無法使用 Windows Time 的服務來校時)
至於為何在完成校時的同時 Root Dispersion 不會馬上變成 1 秒以下,原因不明!
—————————————————————-
Cisco NTP Associations
cisco的NTP Associations(關係) 有分兩種:
1.peer:
Peer之間可互相同步
指令:ntp peer [ip]
2.server/Client:
server 同步client, client 只收受同步, 不發訊息給any other device
指令:
在client上設置,ntp server [ip]
在Server上設置,ntp master 1
所以要成為哪種mode(peer, server, client), 要取決於同步的flow.
Cisco NTP Associations
cisco的NTP Associations(關係) 有分兩種:
1.peer:
Peer之間可互相同步
指令:ntp peer [ip]
2.server/Client:
server 同步client, client 只收受同步, 不發訊息給any other device
指令:
在client上設置,ntp server [ip]
在Server上設置,ntp master 1
所以要成為哪種mode(peer, server, client), 要取決於同步的flow.
成為 NTP 伺服器
指令:ntp master [Stratum level number]
EXAMPLE 1
Router A 和 Router B 對接,Router A 被設為 NTP 主時鐘,Router B被配置成根據 Router A 來同步時鐘。
…
RouterA(config)# int s0
RouterA(config-if)# ip add 172.23.1.1 255.255.255.0
RouterA(config)# ntp master 1
指令:ntp master [Stratum level number]
EXAMPLE 1
Router A 和 Router B 對接,Router A 被設為 NTP 主時鐘,Router B被配置成根據 Router A 來同步時鐘。
…
RouterA(config)# int s0
RouterA(config-if)# ip add 172.23.1.1 255.255.255.0
RouterA(config)# ntp master 1
RouterB(config)# int s0
RouterB(config-if)# ip add 172.23.1.2 255.255.255.0
RouterB(config)# ntp server 172.23.1.1
RouterB(config-if)# ip add 172.23.1.2 255.255.255.0
RouterB(config)# ntp server 172.23.1.1
EXAMPLE 2
路由器A被設置為 NTP 主時鐘,路由器B被配置成通過 NTP 伺服器與路由器A進行時鐘同步,
路由器C則被配置成路由器B的對等體,與B的時鐘同步。
三台路由器通過串口進行連接,路由器A和B之間、路由器B和C之間的連接都使用交叉電纜。
…
RouterA#clock set xx:xx:xx:xx
RouterA(config)# int s0
RouterA(config-if)#ip add 172.23.1.1 255.255.255.0
RouterA# ntp master 1
路由器A被設置為 NTP 主時鐘,路由器B被配置成通過 NTP 伺服器與路由器A進行時鐘同步,
路由器C則被配置成路由器B的對等體,與B的時鐘同步。
三台路由器通過串口進行連接,路由器A和B之間、路由器B和C之間的連接都使用交叉電纜。
…
RouterA#clock set xx:xx:xx:xx
RouterA(config)# int s0
RouterA(config-if)#ip add 172.23.1.1 255.255.255.0
RouterA# ntp master 1
RouterB#ntp server 172.23.1.1
RouterC#ntp peer 172.16.1.2
EXAMPLE 3
使用局域網廣播的CISCO NTP
3台路由器通過乙太網接入同一個網段,路由器a作為NTP伺服器通過e0介面向乙太網發送NTP廣播。
…
RouterA#clock set xx:xx:xx:xx
routerA(config0#int e0
RouterA(config-if)#ip add 172.23.1.1 255.255.255.0
RouterA(config-if)#ntp broadcast
RouterA# ntp master
使用局域網廣播的CISCO NTP
3台路由器通過乙太網接入同一個網段,路由器a作為NTP伺服器通過e0介面向乙太網發送NTP廣播。
…
RouterA#clock set xx:xx:xx:xx
routerA(config0#int e0
RouterA(config-if)#ip add 172.23.1.1 255.255.255.0
RouterA(config-if)#ntp broadcast
RouterA# ntp master
RouterB(config)#int e0
RouterB(config-if) # ip add 172.23.1.2 255.255.255.0
RouterB(config-if) #ntp broadcast client
RouterB(config-if) # ip add 172.23.1.2 255.255.255.0
RouterB(config-if) #ntp broadcast client
RouterC(config)#int e0
RouterC(config-if) # ip add 172.23.1.3 255.255.255.0
RouterC(config-if) #ntp broadcast client
RouterC(config-if) # ip add 172.23.1.3 255.255.255.0
RouterC(config-if) #ntp broadcast client
在Cisco網路系統中的NTP配置需要用到的命令及定義:
ntp access-group: 該全域命令用於路由器N T P服務的存取控制。
ntp authenticate: 是一個全域命令,它啟用N T P身份驗證。
ntp authentication-key: 該全域命令用於定義N T P身份驗證的鍵值。
ntp broadcast: 是一個介面命令,用於server,指定一特定介面來發送N T P廣播包。
ntp broadcast client: 是一個介面命令,用於client,使路由器通過特定介面來接收N T P廣播包。
ntp broadcast delay: 是一個全域命令,它用於設定資料包在路由器和N T P伺服器之間一個回程所需時間的估計值。
ntp clock-period: 這條全域命令不必輸入,當使用N T P進行系統時鐘同步時,路由器將自動產生這條命令。
ntp disable: 這條介面命令使特定介面不接收N T P包。
ntp master: 這條全域命令用來配置路由器為N T P主時鐘,建議當沒有可用的外部N T P源或者為測試用途才使用該命令。
ntp peer: 該全域命令使路由器的系統時鐘與其對等體的時鐘同步(或對對等體的時鐘進行同步)。
ntp server: 該全域命令使路由器的系統時鐘由時間伺服器進行同步。
ntp source: 該全域命令強制路由器在其N T P包中使用特定的源位址。
ntp trusted-key: 該全域命令用於確認路由器的特定身份驗證鍵值。 ntp update-calendar: 該全域命令使 NTP 週期性地更新 router BIOS上的時間。
show ntp status: 是一執行模式命令,用於顯示路由器的NTP資訊,它可以表明該路由器是通過NTP對等體進行時鐘同步還是通過NTP伺服器進行同步。
show ntp association[detail]: 這條執行模式命令顯示與NTP有關的資訊,如輪詢週期等。
ntp access-group: 該全域命令用於路由器N T P服務的存取控制。
ntp authenticate: 是一個全域命令,它啟用N T P身份驗證。
ntp authentication-key: 該全域命令用於定義N T P身份驗證的鍵值。
ntp broadcast: 是一個介面命令,用於server,指定一特定介面來發送N T P廣播包。
ntp broadcast client: 是一個介面命令,用於client,使路由器通過特定介面來接收N T P廣播包。
ntp broadcast delay: 是一個全域命令,它用於設定資料包在路由器和N T P伺服器之間一個回程所需時間的估計值。
ntp clock-period: 這條全域命令不必輸入,當使用N T P進行系統時鐘同步時,路由器將自動產生這條命令。
ntp disable: 這條介面命令使特定介面不接收N T P包。
ntp master: 這條全域命令用來配置路由器為N T P主時鐘,建議當沒有可用的外部N T P源或者為測試用途才使用該命令。
ntp peer: 該全域命令使路由器的系統時鐘與其對等體的時鐘同步(或對對等體的時鐘進行同步)。
ntp server: 該全域命令使路由器的系統時鐘由時間伺服器進行同步。
ntp source: 該全域命令強制路由器在其N T P包中使用特定的源位址。
ntp trusted-key: 該全域命令用於確認路由器的特定身份驗證鍵值。 ntp update-calendar: 該全域命令使 NTP 週期性地更新 router BIOS上的時間。
show ntp status: 是一執行模式命令,用於顯示路由器的NTP資訊,它可以表明該路由器是通過NTP對等體進行時鐘同步還是通過NTP伺服器進行同步。
show ntp association[detail]: 這條執行模式命令顯示與NTP有關的資訊,如輪詢週期等。
###############################################################
■NTP 網路時間協定
NTP (Network Time Protocol)為路由器、交換機和工作站之間提供了一種時間同步的機制。時間同步了,多台網路設備上的相關事件記錄可以放在一起看,更為清晰,方便了分析較複雜的故障和安全事件等。
在一般的情況下也可以使用路由器上的時鐘(system clock)。高檔的路由器/交換機上提供了硬體時鐘,稱為calendar,與clock 相互獨立,在系統重動時clock使用calendar的值。可以用命令 calendar set設置硬體時鐘的值,用命令clock read-calendar 將系統時鐘設置為calendar中的值,也可以用命令clock update-calendar將當前系統時鐘值寫入calendar中。用命令ntp master [n] 將路由器本身設為時鐘源,n為精度級別,默認為8,1是最高精度。在用戶端,用ntp server x.x.x.x 指定NTP伺服器地址(CatOS: set ntp server x.x.x.x),用命令ntp update update-calendar可以讓NTP協議定時更新calendar 的值。如果更改了時鐘源的時間,需要數分鐘才能同步到用戶端,更新calendar需要更長的時間。常用的調試命令有:show ntp status 和show ntp associations等。
注:
1、NTP 的匯聚(convergence)可能需要長達半個小時,這意味著修改NTP主系統時鐘之後,可能要過半個小時才會進行同步.
因為時鐘一般是不需要調整的,如果改變表示時鐘系統不穩定,那麼NTP需在等待系統穩定後才會進行同步和傳遞時鐘的改變.
2、配置了NTP的路由器,同時又使用 clock set 命令配置了另外一個時間 ,根據NTP學來的時間具有更高的優先順序。
1、NTP 的匯聚(convergence)可能需要長達半個小時,這意味著修改NTP主系統時鐘之後,可能要過半個小時才會進行同步.
因為時鐘一般是不需要調整的,如果改變表示時鐘系統不穩定,那麼NTP需在等待系統穩定後才會進行同步和傳遞時鐘的改變.
2、配置了NTP的路由器,同時又使用 clock set 命令配置了另外一個時間 ,根據NTP學來的時間具有更高的優先順序。
相關配置命令:
■ 路由器NTP服務的存取控制
Router(config)# ntp access-group {query-only | serve-only | serve | peer} access-list number
■ NTP的認證
Router(config)# ntp authenticate
Router(config)# ntp authentication-key number md5 value
Router(config)# ntp trusted-key number
■ NTP 以廣播方式同步
Router(config-if)# ntp broadcast (發送方)
Router(config-if)# ntp broadcast client (接收方)
Router(config)# ntp access-group {query-only | serve-only | serve | peer} access-list number
■ NTP的認證
Router(config)# ntp authenticate
Router(config)# ntp authentication-key number md5 value
Router(config)# ntp trusted-key number
■ NTP 以廣播方式同步
Router(config-if)# ntp broadcast (發送方)
Router(config-if)# ntp broadcast client (接收方)
■ 在指定埠不接收 NTP包
Router(config-if)# ntp disable
■ 配置NTP主時鐘
Router(config)# ntp master [Stratum number]
只有當沒有外部NTP源,或者為測試用途才使用此條命令,畢竟路由器作為NTP主時鐘,精確性太差
Stratum number:精度級別,默認為8,取值範圍為
1-5 ,其中1是最高精度
■ 配置路由器的系統時鐘與 時間伺服器 進行同步
Router(config)# ntp server ip-address [key key-id] [source interface]
■ 配置路由器的系統時鐘與其 對等體 的時鐘同步
Router(config)# ntp peer ip-address
Router(config-if)# ntp disable
■ 配置NTP主時鐘
Router(config)# ntp master [Stratum number]
只有當沒有外部NTP源,或者為測試用途才使用此條命令,畢竟路由器作為NTP主時鐘,精確性太差
Stratum number:精度級別,默認為8,取值範圍為
1-5 ,其中1是最高精度
■ 配置路由器的系統時鐘與 時間伺服器 進行同步
Router(config)# ntp server ip-address [key key-id] [source interface]
■ 配置路由器的系統時鐘與其 對等體 的時鐘同步
Router(config)# ntp peer ip-address
■ 強制路由器在其NTP包中使用特定的源位址
Router(config)# ntp source interface number
Router(config)# ntp source interface number
驗證命令:
Router# show ntp status
Router# show ntp association [detail]
Router# show ntp status
Router# show ntp association [detail]
例:
clock timezone cst +8 ;定義中國的時區
clock calendar-valid ;允許使用calendar作為時鐘源
ntp calendar-update ;允許NTP定期更新calendar
ntp master 3 ;允許本機作為NTP協議的主時鐘
精度級別3,供其它對等體同步用
ntp authenticate ;配置NTP認證
ntp authentication-key 1234 md5 104D000A0618 7
ntp trusted-key 1234
ntp server 192.168.100.1 ;用戶端配置
要求:
配置網路時間協定 NTP ,以使三台路由器時間一致,讓 R1 作時間源
配置網路時間協定 NTP ,以使三台路由器時間一致,讓 R1 作時間源
配置:
R1 的配置:
R1#clock set 11:01:01 1 APR 2006
R1(config)#ntp master
R1 的配置:
R1#clock set 11:01:01 1 APR 2006
R1(config)#ntp master
R2,R3 的配置:
R2(config)#ntp server
192.168.12.1
R3(config)#ntp server
192.168.12.1
R2(config)#ntp server
192.168.12.1
R3(config)#ntp server
192.168.12.1
驗證
R2#show clock
11:07:39.627 UTC Sat Apr 1 2006
R2#show clock
11:07:39.627 UTC Sat Apr 1 2006
R2#show ntp status
Clock is synchronized, stratum 2,
reference is 192.168.12.1
nominal freq is 250.0000 Hz, actual freq is 249.9999 Hz,
precision is 2**18
reference time is C7D8DD77.F0DF60CC (11:07:35.940
UTC Sat Apr 1 2006)
clock offset is 3.6650 msec, root delay is 28.95 msec
root dispersion is 4.91 msec, peer dispersion is 1.22
msec
R2#show ntp association
address
ref clock
st when poll
reach delay offset disp
*~192.168.12.1 .LOCL.
1
38 64 377
29.0 4.32 1.2
* master (synced), # master (unsynced), + selected, –
candidate, ~ configured
address
ref clock
st when poll
reach delay offset disp
*~192.168.12.1 .LOCL.
1
38 64 377
29.0 4.32 1.2
* master (synced), # master (unsynced), + selected, –
candidate, ~ configured
注:這裡的38表示,R2在38秒之前收到最後一個 NTP 更新資訊
###################################
NTP 發送週期性 組播包保持更新
工作於組播模式下,不需要週期性去查詢
伺服器端
Router1(config)#clock timezone EST -5
Router1(config)#clock summer-time EDT recurring
Router1(config)#clock timezone EST -5
Router1(config)#clock summer-time EDT recurring
Router1(config)#ntp server 172.25.1.1
Router1(config)#ntp server 172.25.1.3
Router1(config)#interface FastEthernet 0/0
Router1(config)#ntp server 172.25.1.3
Router1(config)#interface FastEthernet 0/0
Router1(config-if)#ntp multicast 224.0.1.1 ttl 1
用戶端
Router1(config)#clock timezone EST -5
Router1(config)#clock summer-time EDT recurring
Router1(config)#clock summer-time EDT recurring
Router1(config)#ntp server 172.25.1.1
Router1(config)#ntp server 172.25.1.3
Router1(config)#interface FastEthernet 0/0
Router1(config-if)#ntp multicast 224.0.1.1 ttl 1
注:組播相對於廣播的好處不用多說了,並且在這個模式的初始用戶端會先發送一些單播包來測量
延遲,以使時間更準確,需要注意的是不是所有的設備都支援這種組播模式
延遲,以使時間更準確,需要注意的是不是所有的設備都支援這種組播模式
限制 NTP PEERS 數目
限制路由器可以接受的 NTP Peers的數目
Router(config)#ntp max-associations 30
如:
Router(config)#access-list 88 permit host 172.25.1.1
Router(config)#access-list 88 permit host 10.1.1.1
Router(config)#access-list 99 permit 172.25.0.0 0.0.255.255
Router(config)#access-list 99 permit 10.2.0.0 0.0.255.255
Router(config)#clock timezone EST -5
Router(config)#clock summer-time EDT recurring
Router(config)#ntp server 172.25.1.1 version 3
Router(config)#ntp server 10.1.1.1 version 3
Router(config)#ntp access-group peer 88
Router(config)#ntp access-group serve-only 99

沒有留言:
張貼留言