發新話題
打印

路由器的NTP(网络时钟协议)配置

路由器的NTP(网络时钟协议)配置

Network Time Protocol(NTP)是用来使计算机时间同步化的一种协议,它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1毫秒,WAN上几十毫秒),且可介由加密确认的方式来防止恶毒的协议攻击。  配置NTP首先组要创建一个连接。使用下列命令初始化连接的配置:  ntp server ip _address [version number][key key_id][source interface][prefer]  ntp peer ip _address [version number][key key_id][source interface][prefer]  假如路由器将和另一个NTP时钟同步,则建立一个服务器连接。假如路由器不但与另一个设备  同步,而且答应其他设备和该路由器同步,则创建一个对等连接。缺省的版本时3,缺省情况下,没有配置认证key id,源IP地址发送端口的IP地址,prefer告诉IOS该同步对等体的优先级。  为控制对路由器NTP服务的访问,使用下面的命令:  ntp access-group {query|serve-only|serve|peer} access-list-number  query-only:答应从列出的IP地址发出NTP控制查询。控制查询用在监视NTP进程的SNMP网络           治理工作站。  serve-only:答应访问控制列表上的IP地址请求事件,路由器不向远程系统同步时间。  serve:答应时间请求和控制查询,路由器同样不向远程系统同步时间。  peer:答应时请求和控制查询,并且答应路由器从远程系统同步时间。  例:Seattle

access-list 1 permit 172.16.0.0 0.0.255.255

access-list 2 permit 128.10.39.11

ntp access-group peer 2

ntp access-group serve 1

ntp server 128.105.39.11

Tacoma

ntp server 172.16.1.5   以上配置答应路由器:Settle从一个公共的二级时钟源同步,在与Seattle同一个网络上的另一个路由器Tacoma被答应从Seattle获得同步。NTP 时间时UTC.假如希望路由器保持在另一个时区,你可以使用下列命令保持本地时间:clock timezone pst -8

clock summer-time PDT recurring   使用ntp update-calendar 命令使路由器用NTP获得的时间更新内部日历。  NTP的认证:ntp authentication

ntp authentication-key number md5 key

ntp trusted-key number

ntp server ip-address key number   ntp authentication 必须配置在NTP服务器和请求时间同步的路由器。(在全局下)。  ntp authentication-key 需要配置在所有路由器,该命令定义的认证串并将其赋值。  请求时间同步的路由器使用ntp trusyed-key命令配置。该命令列出了ntp authentication-key  命令定义的认证串的数值,该数值必须包含在NTP 同步请求包中。所以ntp trusted-key只  配置在客户路由器端。  key number必须包含在客户的ntp server命令中,该命令将密码包含到客户发往服务器的NTP包中。当路由器看到密码,假如该密码在服务器中有定义,则将密码包含到发往客户的NTP包中。  例:Seattle

ntp authencation

ntp authencation-key 10 md5 ntpkey

Tacoma

ntp authencation

ntp authencation-key 10 md5 ntpkey

ntp trusted-key 10

ntp server seattle key 10   Tacoma的ntp server seattle key 10命令指定在Tacoma 与Seattle时钟同步以前,服务器Seattle必须在NTP包中提供10号密码。从Tacoma的包中,Seattle看到10号密码。  Seattle 中的ntp authentication-key 10 md5 ntpkey命令可以使Seattle在对Tacoma的应答包中包含认证密码10.  排错:show ntp status

sh ntp association detail

TOP

發新話題