33-NTP命令
本章节下载 (190.57 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
& 说明:
S5600以太网交换机为防止恶意用户对未使用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服务器模式外,其余的NTP工作模式均会建立连接。
【举例】
# 显示NTP服务维护的所有会话的状态。
<H3C> 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
表1-1 display ntp-service sessions命令显示信息描述表
字段 |
描述 |
source |
同步源的IP地址 |
reference |
同步源的参考时钟ID |
stra |
同步源的时钟层数 |
reach |
是否可达 |
poll |
轮询间隔,即两个连续消息之间的最大间隔,单位为秒 |
now |
最近一次发送NTP报文到现在的时间间隔 |
offset |
时钟偏差 |
delay |
网络延时 |
disper |
本地时钟相对与参考时钟的最大误差 |
【命令】
display ntp-service status
【视图】
任意视图
【参数】
无
【描述】
display ntp-service status命令用来显示NTP服务的状态信息。
【举例】
# 显示本地NTP服务的状态信息。
<H3C> display ntp-service status
Clock status: unsynchronized
Clock stratum: 16
Reference clock ID: none
Nominal frequency: 60.0002 Hz
Actual frequency: 60.0002 Hz
Clock precision: 2^18
Clock offset: 0.0000 ms
Root delay: 0.00 ms
Root dispersion: 0.00 ms
Peer dispersion: 0.00 ms
Reference time: 00:00:00.000 UTC Jan 1 1900(00000000.00000000)
显示信息的解释如表1-2所示。
表1-2 display ntp-service status命令显示信息描述表
字段 |
描述 |
Clock status |
本地时钟状态 |
Clock stratum |
本地时钟的层数 |
Reference clock ID |
当本地系统已被同步到一个远程NTP服务器或某个时钟源时,指示远程服务器的地址或时钟源的标识 |
Nominal frequency |
本地系统硬件时钟的标称频率 |
Actual frequency |
本地系统硬件时钟的实际频率 |
Clock precision |
本地系统时钟的精度 |
Clock offset |
本地时钟相对NTP服务器的偏移量 |
Root delay |
本地到主参考时钟总的往返延迟时间 |
Root dispersion |
本地相对主参考时钟的最大误差 |
Peer dispersion |
远程NTP服务器的最大误差 |
Reference time |
参考时间戳 |
【命令】
display ntp-service trace
【视图】
任意视图
【参数】
无
【描述】
display ntp-service trace命令用来显示从本地设备沿着时间同步NTP服务器链,回溯到参考时钟源的各个NTP时间服务器的简要信息。
【举例】
# 显示从本地设备回溯到参考时钟源的路径中各NTP服务器的简要信息。
<H3C> 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 }
【视图】
系统视图
【参数】
peer:可以对本地NTP服务器进行时间请求和查询,本地时钟也可以同步到远程服务器。
server:允许对本地NTP服务器进行时间请求与查询,但本地时钟不会同步到远程服务器。
synchronization:只允许对本地NTP服务器进行时间请求。
query:只允许对本地NTP服务器进行查询。
acl-number:基本访问控制列表号,取值范围为2000~2999。
【描述】
ntp-service access命令用来设置对本地交换机NTP服务器的访问控制权限。undo ntp-service access命令用来取消设置的访问控制权限。
缺省情况下,对本地NTP服务器的访问控制权限为peer。
ntp-service access命令提供了一种最小限度的安全措施,更安全的方法是进行身份验证。当本地NTP服务器有一个访问请求时,该请求按照最大访问权限到最小访问权限依次匹配,匹配顺序为peer、server、synchronization、query。
【举例】
# 设置允许第2076号访问列表中的对端可以对本地设备具有完全访问权限,包括时间请求、查询控制及时间同步。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] ntp-service access peer 2076
# 只允许第2028号访问列表中的对端对本地设备具有访问和查询权限。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] 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身份验证功能。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] 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。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] 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广播消息。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] interface Vlan-interface1
[H3C-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。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] interface Vlan-interface 1
[H3C-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报文。
缺省情况下,允许接口接收NTP报文。
【举例】
# 禁止Vlan-interface1接口接收NTP报文。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] interface Vlan-interface 1
[H3C-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命令用来恢复会话数目为缺省值。
缺省情况下,本地允许建立的动态会话数目为100.
【举例】
# 设置本地允许建立的NTP会话的数目为50个。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] 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接口下配置了多条NTP组播客户端的命令时,取消其中一条的配置,不会影响该接口下其他NTP组播客户端配置的正常运行。
【举例】
# 配置在Vlan-interface1接口上接收NTP组播消息包,组播消息包对应的组播组地址为224.0.1.1。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] interface Vlan-interface 1
[H3C-Vlan-interface1] ntp-service multicast-client 224.0.1.1
【命令】
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.1,用4号密钥进行加密,设置NTP版本号为3。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] interface Vlan-interface 1
[H3C-Vlan-interface1]ntp-service multicast-server 224.0.1.1
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,指定该密钥为可信密钥。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] ntp-service authentication enable
[H3C] ntp-service authentication-keyid 37 authentication-mode md5 BetterKey
[H3C] ntp-service reliable authentication-keyid 37
【命令】
ntp-service source-interface interface-type interface-number
undo ntp-service source-interface
【视图】
系统视图
【参数】
interface-type interface-number:指定接口,使用其IP地址作为发出的NTP报文中的源IP地址。interface-type表示指定接口的类型,interface-number表示指定接口的编号。
【描述】
ntp-service source-interface命令用来指定本地发送NTP报文的接口。undo ntp-service source-interface命令用来取消当前配置。
当不想本地设备上其它接口的IP地址成为应答消息的目的地址时,可以使用该命令指定一个特定接口来发送所有的NTP消息包。此时消息包中的源IP地址都用该接口的IP地址。
【举例】
# 指定NTP所有输出消息包的源IP地址都用VLAN-interface1的IP地址。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] ntp-service source-interface Vlan-interface 1
【命令】
ntp-service unicast-peer { remote-ip | peer-name } [ authentication-keyid key-id | priority | source-interface interface-type interface-number | 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 interface-type interface-number:指定一个接口。本地设备给对端发送NTP消息时,消息包中的源IP地址为该接口的IP地址。interface-type为接口类型,interface-number为接口编号。
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获得。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] 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 interface-type interface-number | 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 interface-type interface-number:指定一个接口。本地设备给服务器发送NTP消息时,消息包中的源IP地址为该接口的IP地址。interface-type为接口类型,interface-number为接口编号。
version number:指定NTP版本号。number的取值范围为1~3,缺省版本号为3。
【描述】
ntp-service unicast-server命令用来配置以太网交换机工作在NTP客户端模式。undo ntp-service unicast-server命令用来取消NTP客户端模式的配置。
缺省情况下,没有配置以太网交换机工作在NTP客户端模式。
& 说明:
remote-ip所指定的远程服务器作为NTP时间服务器,本地以太网交换机作为客户端,可以同步到NTP服务器,而NTP服务器不会同步到本地客户端。
【举例】
# 配置本地设备由服务器128.108.22.44提供同步时间,版本号为3。
<H3C> system-view
System View: return to User View with Ctrl+Z.
[H3C] ntp-service unicast-server 128.108.22.44 version 3
不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!