学习啦>学习电脑>网络知识>路由器>路由器设置>TP-link>

cisco设置时间

时间: 春健736 分享

  网关都知道cisco路由向来难配置。那么cisco怎么设置时间?学习啦小编整理了相关资料,给大家介绍。有需要学习的同学可参考参考。

  cisco设置时间

  一、人工进行设置CISCO时间

  如果在你配置一个本地时间源或网络时间源之前,一台Cisco路由器就已经启动了,它将显示时间是1993年3月1日。这里是一个示例:

  Router> show clock *00:01:10.415 UTC Mon Mar 1 1993 Router>

  这个在Log文件中出现的日期,是尚未有人设置过路由器的时间源或本地时间的良好标志。而路由器log入口的确是从1993年开始的可能性则小的多。

  在一个路由器上正确设置时间,真的那么重要么?虽然正确的时间设置对一个路由器的完全运作并非必需,但是那并不意味着你不应设置正确的时间。在路由器上正确设置时间,有下述益处:

  1.Log文件会显示正确的时间标记,可以帮助解决疑难问题。

  2.正确的时间允许你在两个完全不同的时期内建立连接。

  3.你可以通过路由器的Kron调度程序,安排在指定的时间执行命令。

  设置时区

  要正确设置一个路由器(或交换机)的时间,首要的第一步是设定正确的时区。这成为第一步的理由是:如果你先设定了时间,而后再设定时区,那么你将不得不再次重新设定时间。

  要记住的关键点是,仅仅知道你是在东部或者西部时区是不够的。你需要知道你所在地区离格林威治标准时间(GMT,Greenwich Mean Time)相差多少小时。

  举例来说,如果你在美国的东部标准时区,你落后GMT时间5个小时。你应当设置路由器为-5.如果你不确定你和GMT时间到底相差多少,美国海军的网站提供了一个很好的资源--世界时区分布地图。

  在你已经确定了你的时区值后,你就可以设定时区了。举例来说,我住在中部标准时区(CST,Central Standard Time),那么我是这么设置路由器的:

  Router(config)# clock timezone GMT 8

  设置夏令时

  设定了正确的时区之后,你需要设定路由器,是否需要调节夏令时。你可以使用summer-time命令来完成这点。照例使用我们的CST作为示例,下面是如何进行夏令时设置的命令:

  Router(config)# clock summer-time CDT recurring

  Summer命令告诉路由器引用的夏令时是CDT(中部夏令时,Central Daylight Time),路由器会自动根据自身预先设定好的日期和时间而对时间进行调校。(你可以使用同样的命令进行人工设置夏令时)。而recurring的选项则告知路由器,使用公认的美国夏令时规则进行每年一次的4月和10月时间变更。

  设置时钟

  设定完毕时区和夏令时后,最后的一步就是设定路由器的时间。你必须在特权模式(Privileged Mode),而不是全程设定模式(Global Configuration Mode)

  如果你以前从未这么做过,格式可能有点点复杂。这里是你需要注意的一些事项:

  使用clock set命令

  使用军用时间。

  设定时间时需要指定"秒数"

  使用特定的3位缩写输入月份

  加上日期和年份

  下面是一个示例:

  Router# clock set 10:50:00 Oct 26 2006

  察看时间

  配置完毕时区,夏令时,以及时间后,你可以使用show clock命令查看时间。下面是一个事例:

  Router# show clock

  10:51:33.208 CDT Thu Oct 19 2006

  Router#

  要留意,绝大多数Cisco路由器和交换机都没有内部时钟,所以无法保存时间,也就是关掉机器将会丢失时间设置。这意味着重起一台设备也将丢失本地时间。而唯一不会改变的是时区设置,因为路由器在它的配置文件中对其进行了保存

  调整显示log和debug时间方式

  有些时候Cisco 交换机的日志显示是X年X周的格式(如1y21w),怎么样设置才可以让Log显示年月日和时间

  siwtch(config)#service timestamps debug datetime msec localtime show-timezone

  siwtch(config)#service timestamps log datetime msec localtime show-timezone

  二、cisco路由器定时执行命令

  Router#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router(config)#kron policy-list NEOSHI

  Router(config-kron-policy)#cli write memory

  Router(config-kron-policy)#exit

  Router(config)#kron occurrence DAILYat5 at 17:00 recurring

  Router(config-kron-occurrence)#policy-list NEOSHI

  Router(config-kron-occurrence)#end

  Router#

  注释 从IOS12.3(1)开始引入了这个类似Unix Cron 的特性,不过也有一些缺点,只能运行EXEC 模式下的命令,不能运行配置模式下的命令,同时输入的命令不能是交互性的,比如不能输入copyrunning-config startup-config 来保存配置,因为是需要确认的,必须使用write memory 来代替

  system clock与system calendar分别

system clock system calendar
system clock是基于软件的 system calendar是基于硬件的calendar不受开关机和重起的影响
通常他只被设一次

  Manually Setting the Software Clock

clock set hh:mm:ss date month year
时 :分: 秒 日 月 年
Month 必须是字母,不能是数字

  Set the Calendar from the Clock or NTP

clock update-calendar Set the Calendar from the Clock
ntp update-calendar Set the Calendar from NTP
用NTP周期性更新system calendar

  Set the system clock from the system calendar

clock read-calendar 这语句使clock重读system calendar
通常是系统重起的时候,system clock读system calendar
进行clock inital.

  Setting the Router as a Network Time Source

clockcalendar-valid make the system calendar be authoritative
Enables the router to act as a valid time source to which network peers can synchronize
ntp master clock calendar-valid通常和ntp master一起使用
当用ROUTER做NTP master,而他又不与其他外部TIME SOURCE同步时,就表示他采用的时钟是ROUTER自己的 system calendar,这就要求他必须要authoritative

  clock timezone

clock timezonezonehours-offset [...(minutes-offset)]
时区描述符,时偏移,分偏移

  中国时区:beijing时间是GMT+8区

  GMT时区设置:GMT为格林尼治标准时间,用户可以根据自己所在时区设置GMT时区

clock timezone GMT 8 北京时间

  NTP同步,可以采用三种方法

  ntp server 10.1.1.1 [version ...] [key ...] [source ...(interface)] [prefer]

  ntp peer 10.1.1.1 [normal-sync][version ...] [key ...] [source ...(interface)] [prefer]

  ntp broadcast/ntp broadcast client

  ntp server是单向同步

  ntp server时,router是client mode 对端必须是ntp master

ntp server 10.1.1.1 ntp master

  ntp broadcast

int eth 0
ntp broadcast(send)
!
ntp server 10.9.0.1 prefer
int eth 0
ntp broadcast client(receive)
ntp broadcast 的server端,必须还有正常的NTP配置(NTP SERVER/NTP PEER)

  ntp source

ntp master
ntp source loopback 0

  ntp source loopback 0

  It can be syncronize only if there is path between routers.

  NTP同步经验

  ntp 同步绝对不要等超过三分钟,超过肯定有问题

  就有这种经验,等了15分钟(故意的),一直不同步,结果把ntp server语句no掉,又加上,就同步了

  ntp同步不要怀疑ntp server地址,能ping通即可

  试验通过,ntp server ...不管是对端lo0还是接口地址,都会同步

  ntp source interface ...,配不配都与同步无关

  试验通过,ntp server ... 与对端的ntp source interface没有任何关系

  ntp authentication 三步(别忘了trust-key)

ntp client ntpmaster
ntp server 7.7.3.3 source lo0 key 1
ntp authenticate
ntp authentication-key 1 md5 cisco
ntp trust-key 1
ntp master 2
ntp source lo0
ntp authenticate
ntp authentication-key 1 md5 cisco
ntp trust-key 1
ntp认证三大配置缺一不可,不能因为ntp server ... key 1 就不配ntp trust-key 1

  prefer

  (config)#ntp server 3.3.3.3 ?

  prefer Prefer this peer when possible 配多个ntp server时,取最优先的

558501