思科设备配置时间(NTP)

NTP(Network Time Protocol)网络时间协议:同步设备的时间,可以提供高精准度的时间校正;NTP协议的原和目的端口都是使用UDP 123。

一、服务端

R1(config)# interface Loopback0

R1(config-if)# ip address 1.1.1.1 255.255.255.255

R1(config-if)# ip ospf 1 area 0

R1(config)# interface FastEthernet0/0

R1(config-if)# ip address 10.1.1.1 255.255.255.0

R1(config-if)# ip ospf 1 area 0

R1(config)# clock timezone GMT +8   

//更改为中国的时区,默认为UTC

R1# clock set 16:52:21 29 jan 2020  

//将时间设置为2020年1月29日16点52分21秒,jan为1月份英文的缩写,星期不用设置会自动推算得出

R1(config)# ntp master 1   

//设置NTP为master(主),精准度为1(默认为8)

R1(config)# ntp source loopback 0     

//建议使用环回口传输

 

二、客户端

R2(config)# interface Loopback0

R2(config-if)# ip address 2.2.2.2 255.255.255.255

R2(config-if)# ip ospf 1 area 0

R2(config)# interface FastEthernet0/0

R2config-if)# ip address 10.1.1.2 255.255.255.0

R2(config-if)# ip ospf 1 area 0

R2(config)# clock timezone GMT +8     //客户端记得也要改时区

R2(config)# ntp server 1.1.1.1          //指定NTP服务器IP地址

R2(config)# ntp source loopback 0

R2(config)# ntp server 202.112.10.36 source FastEthernet0/0   /如果可以访问互联网,可直接使用互联网的NTP服务器同步时间

 

R2# show clock         

//查看时间,时间前面带的符号所代表:

  空格:时钟被手动设置,或者和NTP时间服务器同步

* 星号:时钟没有被设置,或者没有和NTP服务器同步

. 句号:时钟被设置为同步,但和NTP服务器失去了联系

R2# show ntp status   //查看NTP的同步状态,synchronized为同步成功

发布了42 篇原创文章 · 获赞 15 · 访问量 4万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章