cisco 網絡上設備配置NTP

在企業網絡中,配置整個網絡的時間同步是相當重要的,尤其是在分析日誌的工作中,從日誌條目的時間可以發現事件的因果關係。下面以Cisco6509爲例說明交換機時間同步的一些配置代碼。

將CISCO6509配置爲標準時間服務器
ntp server 192.168.0.101

查詢當前的時間
Cisco6509#show clock
00:09:13.643 PDT Tue Jun 30 2009

配置一個北京時區,隨意取名
clock timezone Beijing 8

再查詢一下,已經同步過來了
CISCO6509#show clock
15:10:00.239 Beijing Tue Jun 30 2009

設定硬件時鐘爲權威NTPserver
(config)#clock calendar-valid

調整時間
#clock set 15:00:00 30 jun 2009

當前時鐘爲
#show clock
15:15:10.705 Beijing Tue Jun 30 2009

當前硬件時鐘爲
#show calendar
14:37:59 Beijing Tue Jun 30 2009

NTP源爲vlan2
(config)#ntp source vlan 2

將同步其他時間去除
no ntp server 10.20.0.103

將硬件時鐘與當前clock同步
#clock update-calendar

查看當前clock時間
#show clock
.15:47:57.558 Beijing Tue Jun 30 2009

查看當前硬件時鐘
#show calendar
15:48:00 Beijing Tue Jun 30 2009

配置系統debug記錄的時間格式
(config)#service timestamps debug datetime localtime

配置系統日誌記錄時間格式
(config)#service timestamps log datetime localtime

設置與其他時間服務器同步
(config)#ntp server 192.168.0.102

設置爲第一級ntp服務器
(config)#ntp master 1

允許更新硬件時鐘(不必須)
(config)#ntp update-calendar

 

查看的ntp設置的命令
sh clock detail
sh ntp sta
sh ntp ass
sh ntp ass detail

 

 

----配置命令

ntp authentication-key 1 md5 xx
ntp source Loopback0
ntp server 10.10.10.1 key 1

 

 

 配置方法:

  // router 7206

  conf t

  ntp source FastEthernet0/1   //指定更新源地址,覆蓋ntp server中的配置

  ntp update-calendar      //設備如帶有硬件時鐘,同時更新硬件時鐘

  ntp server 202.155.248.218 source FastEthernet0/1  //指定更新目的地址,香港,並指定更新源接口爲f0/1.

  int f0/1

  ntp enable

 

  這時你應該已經獲得了時間,但是注意,時區是否正確,默認爲格林威治時間,如想改爲北京時間,下面這步是必不可少的。

clock timezone BeiJing 8  //最後這個數字8,代表+8時區 認

驗證方法:

 

 

 show ntp associate


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章