1. 程式人生 > >cisco 交換機設定時區、時間、同步日誌本地時間等操作

cisco 交換機設定時區、時間、同步日誌本地時間等操作

Core-Switch-1#show clock

Core-Switch-1#show ntp status

Core-Switch-1#conf t

Core-Switch-1(config)# clock timezone GMT +8

Core-Switch-1(config)#service timestamps debug datetime msec localtime show-timezone

Core-Switch-1(config)#service timestamps log datetime msec localtime show-timezone

Core-Switch-1(config)#exit

Core-Switch-1# clock set 13:51:00 Sep 7 2011

或通過NTP是指ntp伺服器的Key

Core-Switch-1#wr

Core-Switch-1#sh log

預設情況下日誌訊息不包括日期和時間戳。

service timestamps {debug | log } uptime

service timestamps {debug | log } datetime [mesc] [localtime] [show-timezone] [year]

debug引數在除錯輸出時包括時間戳log引數在每種日誌訊息中新增一個時間戳

uptime在訊息中包括路由器開機以來的時間

0w2d:#SYS-5-CONFIG_I : Configured from console by console
0w2d 開機後02

datetime顯示準確的日期和時間 UTC 格式標準格式 MM DD HH:MM:SS

datetime後面可以跟一些引數

mesc訊息中包括毫秒資訊localtime顯示基於本地配置的時區時間show-timezone輸出包括時區名稱year輸出包括年份資訊

未設定時間前:

#sh log

4w0d: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/6, changed state to up

4w0d: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/6, changed state to down

4w0d: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/6, changed state to up

4w1d: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to down

4w1d: %LINK-3-UPDOWN: Interface FastEthernet0/5, changed state to down

4w1d: %LINK-3-UPDOWN: Interface FastEthernet0/5, changed state to up

4w1d: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to up

4w1d: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down

4w1d: %LINK-3-UPDOWN: Interface FastEthernet0/3, changed state to down

4w1d: %LINK-3-UPDOWN: Interface FastEthernet0/3, changed state to up

4w1d: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up

設定後

#sh log

.Sep  7 05:59:22: %SYS-6-CLOCKUPDATE: System clock has been updated from 13:59:22 BJ Wed Sep 7 2011 to 05:59:22 UTC Wed Sep 7 2011, configured from console by wht on vty2 (172.16.100.10).

.Sep  7 13:59:23: %SYS-6-CLOCKUPDATE: System clock has been updated from 05:59:23 UTC Wed Sep 7 2011 to 13:59:23 GMT Wed Sep 7 2011, configured from console by wht on vty2 (172.16.100.10).

.Sep  7 13:59:24: %SYS-5-CONFIG_I: Configured from console by wht on vty2 (172.16.100.10)

.Sep  7 13:58:00: %SYS-6-CLOCKUPDATE: System clock has been updated from 14:00:05 GMT Wed Sep 7 2011 to 13:58:00 GMT Wed Sep 7 2011, configured from console by wht on vty2 (172.16.100.10).