NTP(Network Time Protocol,网络时间协议)是基于RFC1305的协议,是一个跨越广域网或局域网的复杂的同步时间协议。一般情况下建议配置在路由器上,当然配置在其它设备上都是可以的。接下来我们根据下面的拓扑图来看一下在路由器上配置NTP服务器的方法以及交换机、windows服务器、Linux服务器如何设置NTP客户端。拓扑如下:
路由器NTPserver上配置如下:
R1>en
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#hostname NTPserver
NTPserver(config)#no ip do lo
NTPserver(config)#line con 0
NTPserver(config-line)#exec-t 0 0
NTPserver(config-line)#logg syn
NTPserver(config-line)#exit
NTPserver(config)#int e0/1
NTPserver(config-if)#int e0/0
NTPserver(config-if)#exi
NTPserver(config)#int e0/0
NTPserver(config-if)#ip ad 192.168.1.1 255.255.255.0
NTPserver(config-if)#no shut
NTPserver(config-if)#
*Mar 1 00:02:39.959: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
*Mar 1 00:02:40.959: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
NTPserver(config-if)#clock time
NTPserver(config-if)#do wr
Building configuration...
[OK]
NTPserver(config-if)#exit
NTPserver(config)#cloc
NTPserver(config)#clock time
NTPserver(config)#clock timezone peking +8
NTPserver(config)#
*Mar 1 00:03:27.019: %SYS-6-CLOCKUPDATE: System clock has been updated from 00:03:27 UTC Fri Mar 1 2002 to 08:03:27 peking Fri Mar 1 2002, configured from console by console.
NTPserver(config)#exit
NTPserver#
*Mar 1 00:04:02.975: %SYS-5-CONFIG_I: Configured from console by console
NTPserver#cloc
NTPserver#clock set 12:02:20 6 Aug 2012
NTPserver#
*Aug 6 04:02:20.003: %SYS-6-CLOCKUPDATE: System clock has been updated from 08:04:45 peking Fri Mar 1 2002 to 12:02:20 peking Mon Aug 6 2012, configured from console by console.
NTPserver#conf t
Enter configuration commands, one per line. End with CNTL/Z.
NTPserver(config)#ntp master
第一步:
#int loopback 0
#ip add 1.1.1.1 255.255.255.0 // 定义一个loopback接口地址,用于连接NTP服务器
第二步:
#ntp source Loopback0 //指定本设备用于连接NTP服务器的源地址,自己定义一个地址即可(这里可以选接口或者IP地址都行)
第三步:
#ntp server X.X.X.X //指定NTP服务器的地址