26-NTP命令
本章节下载: 26-NTP命令 (164.71 KB)
目 录
1.1.1 display ntp-service sessions
1.1.2 display ntp-service status
1.1.3 display ntp-service trace
1.1.5 ntp-service authentication enable
1.1.6 ntp-service authentication-keyid
1.1.7 ntp-service broadcast-client
1.1.8 ntp-service broadcast-server
1.1.9 ntp-service in-interface disable
1.1.10 ntp-service max-dynamic-sessions
1.1.11 ntp-service multicast-client
1.1.12 ntp-service multicast-server
1.1.13 ntp-service reliable authentication-keyid
1.1.14 ntp-service source-interface
1.1.15 ntp-service unicast-peer
1.1.16 ntp-service unicast-server
设备为防止恶意用户对未使用SOCKET的攻击,提高设备的安全性,提供了如下功能:
l 在启动NTP功能时,才打开NTP使用的UDP 123端口。
l 在关闭NTP功能时,同时关闭UDP 123端口。
具体的实现是:
l 执行ntp-service unicast-server,ntp-service unicast-peer,ntp-service broadcast-client,ntp-service broadcast-server,ntp-service multicast-client,ntp-service multicast-server六条命令的其中一条,都可以启动NTP功能,同时打开NTP使用的UDP 123端口。
l 使用上面六条命令的undo命令来关闭NTP所有的工作模式,即可同时关闭UDP 123端口。
【命令】
display ntp-service sessions [ verbose ]
【视图】
任意视图
【参数】
verbose:显示NTP会话的详细信息。
【描述】
display ntp-service sessions命令用来显示本地设备NTP服务维护的所有会话信息。
如果display ntp-service sessions命令不使用可选参数verbose,则只显示所有会话的简要信息。
【举例】
# 显示NTP服务维护的所有会话的简要信息。
<device> display ntp-service sessions
source reference stra reach poll now offset delay disper
********************************************************************
[12345]1.1.1.1 127.127.1.0 3 377 512 178 0.0 40.1 22.8
note: 1 source(master),2 source(peer),3 selected,4 candidate,5 configured
Total associations : 1
表1-1 display ntp-service sessions命令显示信息描述表
字段 |
描述 |
source |
同步源的IP地址 |
reference |
同步源的参考时钟ID 当参考时钟为本地时钟时,本字段的显示情况和stra字段的取值有关: l 当stra字段为0或1时,本字段将显示为LOCL l 当stra字段为其他值时,本字段将显示为本地时钟的IP地址 l 当参考时钟为网络中其他设备的时钟时,本字段显示为该设备的IP地址 |
stra |
同步源的时钟层数 |
reach |
时钟源的可达性计数,0表示时钟源不可达 |
poll |
轮询间隔,即两个连续消息之间的最大间隔,单位为秒 |
now |
最近一次发送NTP报文到现在的时间间隔 |
offset |
时钟偏差,单位为毫秒 |
delay |
网络延时,即从本地设备到时钟源的往返时延,单位为毫秒 |
disper |
本地时钟相对与参考时钟的最大误差 |
[12345] |
1:系统选中的时钟源,即当前向其同步的时钟源,且系统时钟层数小于等于15 2:该时钟源的时钟层数小于等于15 3:该时钟源通过了时钟选择流程 4:该时钟源为候选时钟源 5:该时钟源是配置命令所建立的 |
Total associations |
总的连接数 |
l 当设备工作于NTP服务器模式时,不会与其客户端建立会话连接。
l 当工作于其他NTP工作模式时,均会建立会话连接。
【命令】
display ntp-service status
【视图】
任意视图
【参数】
无
【描述】
display ntp-service status命令用来显示NTP服务的状态信息。
【举例】
# 显示本地设备NTP服务的状态信息。
<device> display ntp-service status
Clock status: synchronized
Clock stratum: 4
Reference clock ID: 1.1.1.11
Nominal frequency: 60.0002 Hz
Actual frequency: 60.0002 Hz
Clock precision: 2^18
Clock offset: 0.8174 ms
Root delay: 37.86 ms
Root dispersion: 45.98 ms
Peer dispersion: 35.78 ms
Reference time: 16:30:46.078 UTC Sep 29 2006(C9689FB6.1431593E)
显示信息的解释如表1-2所示。
表1-2 display ntp-service status命令显示信息描述表
字段 |
描述 |
Clock status |
本地时钟状态 |
Clock stratum |
本地时钟的层数 |
Reference clock ID |
当本地时钟已被同步到一个远程NTP服务器或某个时钟源时,指示远程服务器的地址或时钟源的标识 |
Nominal frequency |
本地硬件时钟的标称频率 |
Actual frequency |
本地硬件时钟的实际频率 |
Clock precision |
本地时钟的精度 |
Clock offset |
本地时钟相对参考时钟的偏移量 |
Root delay |
本地设备到主参考时钟源总的往返延迟时间 |
Root dispersion |
本地时钟相对主参考时钟的最大误差 |
Peer dispersion |
远程NTP服务器的最大误差 |
Reference time |
参考时间戳 |
【命令】
display ntp-service trace
【视图】
任意视图
【参数】
无
【描述】
display ntp-service trace命令用来显示从本地设备沿着时间同步NTP服务器链,回溯到参考时钟源的各个NTP时间服务器的简要信息。
【举例】
# 显示从本地设备回溯到参考时钟源的路径中各NTP服务器的简要信息。
<device> display ntp-service trace
server4: stratum 4, offset 0.0019529, synch distance 0.144135
server3: stratum 3, offset 0.0124263, synch distance 0.115784
server2: stratum 2, offset 0.0019298, synch distance 0.011993
server1: stratum 1, offset 0.0019298, synch distance 0.011993 refid 'GPS Receiver'
以上信息显示服务器server4的同步链,表示server4同步到server3,server3同步到server2,server2同步到server1,server1从参考时钟源GPS Receiver得到同步。
【命令】
ntp-service access { peer | server | synchronization | query } acl-number
undo ntp-service access { peer | server | synchronization | query }
【视图】
系统视图
【参数】
query:控制查询权限。该权限只允许远程设备对本地设备的NTP服务进行控制查询,但是不能向本地设备同步时钟。所谓的控制查询,就是查询NTP的一些状态,比如告警信息,验证状态,时钟源信息等。
synchronization:同步权限。该权限只允许远程设备向本地设备同步时钟,但不能进行控制查询。
server:服务器权限。该权限允许远程设备向本地设备同步时钟和控制查询,但本地设备不会向远程设备同步时钟。
peer:对等体权限。该权限既允许远程设备向本地设备同步时钟和控制查询,同时本地设备把本地时钟同步到远程设备。
acl-number:基本访问控制列表编号,取值范围为2000~2999。
【描述】
ntp-service access命令用来设置对本地设备NTP服务器的访问控制权限。undo ntp-service access命令用来取消设置的访问控制权限。
缺省情况下,对本地NTP服务器的访问控制权限为peer。
ntp-service access命令提供了一种最小限度的安全措施,更安全的方法是进行身份验证。当本地NTP服务器有一个访问请求时,该请求按照最大访问权限到最小访问权限依次匹配,匹配顺序为peer、server、synchronization、query。
【举例】
# 设置允许第2076号访问列表中的对端可以对本地设备具有完全访问权限,包括时间请求、查询控制及时间同步。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] ntp-service access peer 2076
# 只允许第2028号访问列表中的对端对本地设备具有访问和查询权限。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] ntp-service access server 2028
【命令】
ntp-service authentication enable
undo ntp-service authentication enable
【视图】
系统视图
【参数】
无
【描述】
ntp-service authentication enable命令用来开启NTP身份验证功能。undo ntp-service authentication enable命令用来关闭NTP身份验证功能。
缺省情况下,NTP身份验证功能处于关闭状态。
【举例】
# 开启NTP身份验证功能。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] ntp-service authentication enable
【命令】
ntp-service authentication-keyid key-id authentication-mode md5 value
undo ntp-service authentication-keyid key-id
【视图】
系统视图
【参数】
key-id:密钥编号,取值范围为1~4294967295。
value:密钥,为1~32个字符的字符串。最大密钥个数为1024。
【描述】
ntp-service authentication-keyid命令用来设置NTP验证密钥。undo ntp-service authentication-keyid命令用来取消NTP验证密钥。
缺省情况下,没有设置NTP验证密钥。
目前系统只支持MD5的密钥验证算法。
【举例】
# 设置MD5身份验证密钥,密钥ID号为10,密钥为BetterKey。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] ntp-service authentication-keyid 10 authentication-mode md5 BetterKey
【命令】
ntp-service broadcast-client
undo ntp-service broadcast-client
【视图】
VLAN接口视图
【参数】
无
【描述】
ntp-service broadcast-client命令用来配置设备工作在NTP广播客户端模式,并使用当前接口接收NTP广播消息。undo ntp-service broadcast-client命令用来取消NTP广播客户端模式配置。
缺省情况下,没有配置设备工作在广播客户端模式。
【举例】
# 配置设备工作在广播客户端模式,并在Vlan-interface1接口上接收NTP广播消息。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] interface Vlan-interface1
[device-Vlan-interface1] ntp-service broadcast-client
【命令】
ntp-service broadcast-server [ authentication-keyid key-id | version number ]*
undo ntp-service broadcast-server
【视图】
VLAN接口视图
【参数】
authentication-keyid key-id:指定向广播客户端发送消息时使用的密钥编号,取值范围为1~4294967295。如果不需要验证,则该参数不需配置。
version number:定义NTP版本号,取值范围为1~3。缺省版本号为3。
【描述】
ntp-service broadcast-server命令用来配置设备工作在NTP广播服务器模式,并使用当前接口发送NTP广播消息包。undo ntp-service broadcast-server命令用来取消NTP广播服务器模式配置。
缺省情况下,没有配置设备工作在NTP广播服务器模式。
【举例】
# 配置在Vlan-interface1接口上发送NTP广播消息包,用4号密钥进行加密,设置NTP版本号为3。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] interface Vlan-interface 1
[device-Vlan-interface1] ntp-service broadcast-server authentication-key 4 version 3
【命令】
ntp-service in-interface disable
undo ntp-service in-interface disable
【视图】
VLAN接口视图
【参数】
无
【描述】
ntp-service in-interface disable命令用来禁止接口接收NTP报文。undo ntp-service in-interface disable命令用来恢复缺省情况。
缺省情况下,允许接口接收NTP报文。
【举例】
# 禁止Vlan-interface1接口接收NTP报文。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] interface Vlan-interface 1
[device-Vlan-interface1] ntp-service in-interface disable
【命令】
ntp-service max-dynamic-sessions number
undo ntp-service max-dynamic-sessions
【视图】
系统视图
【参数】
number:本地允许建立的动态NTP会话的数目,取值范围为0~100。
【描述】
ntp-service max-dynamic-sessions命令用来设置本地允许建立的动态NTP会话的数目。undo ntp-service max-dynamic-sessions命令用来恢复缺省情况。
缺省情况下,本地允许建立的动态NTP会话数目为100。
【举例】
# 设置本地允许建立的动态NTP会话的数目为50个。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] ntp-service max-dynamic-sessions 50
【命令】
ntp-service multicast-client [ ip-address ]
undo ntp-service multicast-client [ ip-address ]
【视图】
VLAN接口视图
【参数】
ip-address:组播IP地址,范围为224.0.1.0~224.0.1.255,缺省为224.0.1.1。
【描述】
ntp-service multicast-client命令用来配置设备工作在NTP组播客户端模式,并使用当前接口接收NTP组播消息包。undo ntp-service multicast-client命令用来取消NTP组播客户端模式配置。
缺省情况下,没有配置设备工作在NTP组播客户端模式。
【举例】
# 配置在Vlan-interface1接口上接收NTP组播消息包,组播消息包对应的组播组地址为224.0.1.2。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] interface Vlan-interface 1
[device-Vlan-interface1] ntp-service multicast-client 224.0.1.2
【命令】
ntp-service multicast-server [ ip-address ] [ authentication-keyid key-id | ttl ttl-number | version number ]*
undo ntp-service multicast-server [ ip-address ]
【视图】
VLAN接口视图
【参数】
ip-address:组播IP地址,范围为224.0.1.0~224.0.1.255,缺省为224.0.1.1。
authentication-keyid key-id:指定向组播客户端发送消息时使用的密钥编号,key-id的取值范围为1~4294967295。
ttl ttl-number:定义组播包的生存期,ttl-number的取值范围为1~255,缺省值为16。
version number:定义NTP版本号,number的取值范围为1~3。缺省版本号为3。
【描述】
ntp-service multicast-server命令用来配置设备工作在NTP组播服务器模式,并使用当前接口发送NTP组播消息包。undo ntp-service multicast-server命令用来取消NTP组播服务器模式配置。
缺省情况下,没有配置设备为组播服务器模式。
【举例】
# 配置在Vlan-interface1接口上发送NTP组播消息包,组播组地址为224.0.1.2,用4号密钥进行加密,并设置NTP版本号为3。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] interface Vlan-interface 1
[device-Vlan-interface1]ntp-service multicast-server 224.0.1.2
authentication-keyid 4 version 3
【命令】
ntp-service reliable authentication-keyid key-id
undo ntp-service reliable authentication-keyid key-id
【视图】
系统视图
【参数】
key-id:密钥编号,取值范围为1~4294967295。
【描述】
ntp-service reliable authentication-keyid命令用来指定密钥是可信的,当启用身份验证时,客户端只会同步到提供可信密钥的服务器,如果服务器提供的密钥不是可信密钥,客户端不会与其同步。undo ntp-service reliable authentication-keyid命令用来取消指定的可信密钥。
缺省情况下,没有配置可信密钥。
【举例】
# 设置启用NTP身份验证,采用MD5加密方法,密钥ID号为37,密钥为BetterKey,并指定该密钥为可信密钥。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] ntp-service authentication enable
[device] ntp-service authentication-keyid 37 authentication-mode md5 BetterKey
[device] ntp-service reliable authentication-keyid 37
【命令】
ntp-service source-interface Vlan-interface vlan-id
undo ntp-service source-interface
【视图】
系统视图
【参数】
Vlan-interface vlan-id:指定接口,使用其IP地址作为发出的NTP报文中的源IP地址。vlan-id表示指定VLAN接口的编号。
【描述】
ntp-service source-interface命令用来指定本地发送NTP报文的接口。undo ntp-service source-interface命令用来取消当前配置。
当不想本地设备上其它接口的IP地址成为应答消息的目的地址时,可以使用该命令指定一个特定接口来发送所有的NTP消息包。此时消息包中的源IP地址都用该接口的IP地址。
【举例】
# 指定NTP所有输出消息包的源IP地址都用VLAN-interface1的IP地址。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] ntp-service source-interface Vlan-interface 1
【命令】
ntp-service unicast-peer { remote-ip | peer-name } [ authentication-keyid key-id | priority | source-interface Vlan-interface vlan-id | version number ]*
undo ntp-service unicast-peer { remote-ip | peer-name }
【视图】
系统视图
【参数】
remote-ip:NTP被动对等体的IP地址,不能为广播、组播地址或本地时钟使用的IP地址。
peer-name:被动对等体主机名,取值为1~20个字符的字符串。
authentication-keyid key-id:指定向对等体发送消息使用的密钥编号,取值范围为1~4294967295。缺省情况下,没有开启身份验证功能。
priority:优先选择remote-ip所指定的对等体为同步对等体。
source-interface Vlan-interface vlan-id:指定一个接口。本地设备给对端发送NTP消息时,消息包中的源IP地址为该接口的IP地址。vlan-id:VLAN接口编号。
version number:定义NTP版本号,number的取值范围为1~3。缺省版本号为3。
【描述】
ntp-service unicast-peer命令用来配置设备为NTP主动对等体。undo ntp-service unicast-peer命令用来取消NTP主动对等体配置。
缺省情况下,没有配置本地设备为NTP主动对等体。
remote-ip所指定的远程设备作为本地设备的对等体,本地设备运行在主动对等体模式。此时,本地设备可以同步到远程设备,而远程设备也能同步到本地设备。
【举例】
# 本地设备被配置成由peer 128.108.22.44提供同步时间,本地对等体也能为peer提供同步时间,版本号为3。NTP消息包的IP地址从Vlan-interface1获得。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] ntp-service unicast-peer 128.108.22.44 version 3 source-interface Vlan-interface 1
【命令】
ntp-service unicast-server { remote-ip | server-name } [ authentication-keyid key-id | priority | source-interface Vlan-interface vlan-id | version number ]*
undo ntp-service unicast-server { remote-ip | server-name }
【视图】
系统视图
【参数】
remote-ip:NTP服务器IP地址,不能为广播、组播地址或本地时钟使用的IP地址。
server-name:NTP服务器的主机名,取值为1~20个字符的字符串。
authentication-keyid key-id:指定向NTP服务器发送消息使用的密钥编号。key-id的取值范围为1~4294967295。缺省时,启用身份验证。
priority:remote-ip或server-name所指定的服务器为优先选择的服务器。
source-interface Vlan-interface vlan-id:指定一个接口。本地设备给服务器发送NTP消息时,消息包中的源IP地址为该接口的IP地址。vlan-id为接口编号。
version number:指定NTP版本号。number的取值范围为1~3,缺省版本号为3。
【描述】
ntp-service unicast-server命令用来配置设备工作在NTP客户端模式。undo ntp-service unicast-server命令用来取消NTP客户端模式的配置。
缺省情况下,没有配置设备工作在NTP客户端模式。
remote-ip所指定的远程设备作为NTP时间服务器,本地设备作为客户端,可以同步到NTP服务器,而NTP服务器不会同步到本地客户端。
【举例】
# 配置本地设备由NTP服务器128.108.22.44提供同步时间,版本号为3。
<device> system-view
System View: return to User View with Ctrl+Z.
[device] ntp-service unicast-server 128.108.22.44 version 3
不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!