• 产品与解决方案
  • 行业解决方案
  • 服务
  • 支持
  • 合作伙伴
  • 新华三人才研学中心
  • 关于我们

H3C S3100-UM[S3100-SI(UM)]系列以太网交换机 命令手册-Release 22XX系列-6W101

27-NTP命令

本章节下载  (170.85 KB)

docurl=/cn/Service/Document_Software/Document_Center/Switches/Catalog/S3100/S3100-SI(UM)/Command/Command_Manual/H3C_S3100-SI(UM)-Release_22XX-6W101/201108/722211_30005_0.htm

27-NTP命令


1 NTP配置命令

本系列以太网交换机为防止恶意用户对未使用SOCKET的攻击,提高交换机的安全性,提供了如下功能:

l    在启动NTP功能时,才打开NTP使用的UDP 123端口。

l    在关闭NTP功能时,同时关闭UDP 123端口。

具体的实现是:

l    执行ntp-service unicast-serverntp-service unicast-peerntp-service broadcast-clientntp-service broadcast-serverntp-service multicast-clientntp-service multicast-server六条命令的其中一条,都可以启动NTP功能,同时打开NTP使用的UDP 123端口。

l    使用上面六条命令的undo命令来关闭NTP所有的工作模式,即可同时关闭UDP 123端口。

 

1.1  NTP配置命令

1.1.1  display ntp-service sessions

【命令】

display ntp-service sessions [ verbose ]

【视图】

任意视图

【参数】

verbose:显示NTP会话的详细信息。如不指定该参数,则只显示所有会话的简要信息。

【描述】

display ntp-service sessions命令用来显示本地交换机NTP服务维护的所有会话信息。

【举例】

# 显示NTP服务维护的所有会话的简要信息。

<Sysname> display ntp-service sessions

     source        reference       stra reach poll  now offset  delay disper

*************************************************************************

[12345]3.0.1.32    LOCL               1    95   64   42  -14.3   12.9    2.7

[25]3.0.1.31    127.127.1.0          2     1   64    1 4408.6   38.7    0.0

note: 1 source(master),2 source(peer),3 selected,4 candidate,5 configured

Total associations :  2

表1-1 display ntp-service sessions命令显示信息描述表

字段

描述

source

同步源的IP地址

reference

同步源的参考时钟ID

(1)      当参考时钟为本地时钟时,本字段的显示情况和stra字段的取值有关:

l      当stra字段为0或1时,本字段将显示为LOCL;

l      当stra字段为其他值时,本字段将显示为本地时钟的IP地址

(2)      当参考时钟为网络中其他交换机的时钟时,本字段显示为该交换机的IP地址

stra

同步源的时钟层数

reach

时钟源的可达性计数,0表示时钟源不可达

poll

轮询间隔,即两个连续消息之间的最大间隔,单位为秒

now

最近一次发送NTP报文到现在的时间间隔

offset

时钟偏差,单位为毫秒

delay

网络延时,即从本地交换机到时钟源的往返时延,单位为毫秒

disper

本地时钟相对与参考时钟的最大误差

[12345]

1:系统选中的时钟源,即当前向其同步的时钟源,且系统时钟层数小于等于15

2:该时钟源的时钟层数小于等于15

3:该时钟源通过了时钟选择流程

4:该时钟源为候选时钟源

5:该时钟源是配置命令所建立的

Total associations

总的连接数

 

l    当本系列交换机工作于NTP服务器模式时,不会与其客户端建立会话连接。

l    当本系列交换机工作于其他NTP工作模式时,均会建立会话连接。

 

1.1.2  display ntp-service status

【命令】

display ntp-service status

【视图】

任意视图

【参数】

【描述】

display ntp-service status命令用来显示NTP服务的状态信息。

【举例】

# 显示本地交换机NTP服务的状态信息。

<Sysname> display ntp-service status

 Clock status: synchronized

 Clock stratum: 4

 Reference clock ID: 1.1.1.11

 Nominal frequency: 100.0000 Hz

 Actual frequency: 100.0000 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 Mar 29 2007(C9689FB6.1431593E) 

显示信息的解释如表1-2所示。

表1-2 display ntp-service status命令显示信息描述表

字段

描述

Clock status

本地时钟状态,可以为synchronized或unsynchronized

Clock stratum

本地时钟的层数

Reference clock ID

当本地时钟已被同步到一个远程NTP服务器或某个时钟源时,指示远程服务器的地址或时钟源的标识

Nominal frequency

本地硬件时钟的标称频率,单位为Hz

Actual frequency

本地硬件时钟的实际频率,单位为Hz

Clock precision

本地时钟的精度

Clock offset

本地时钟相对参考时钟的偏移量,单位为毫秒

Root delay

本地交换机到主参考时钟源总的往返延迟时间,单位为毫秒

Root dispersion

本地时钟相对主参考时钟的最大误差,单位为毫秒

Peer dispersion

远程NTP服务器的最大误差,单位为毫秒

Reference time

参考时间戳

 

1.1.3  display ntp-service trace

【命令】

display ntp-service trace

【视图】

任意视图

【参数】

【描述】

display ntp-service trace命令用来显示从本地交换机沿着时间同步NTP服务器链,回溯到参考时钟源的各个NTP时间服务器的简要信息。

【举例】

# 显示从本地交换机回溯到参考时钟源的路径中各NTP服务器的简要信息。

<Sysname> display ntp-service trace

 server 127.0.0.1,stratum 3, offset 0.018739, synch distance 0.04724

 server 172.1.2.3,stratum 2, offset 0.030714, synch distance 0.01094

 refid LOCL

以上信息显示了服务器127.0.0.1的同步链,表示服务器127.0.0.1同步到服务器172.1.2.3,服务器172.1.2.3从本地时钟源得到同步。

表1-3 display ntp-service trace命令显示信息描述表

字段

描述

server

NTP时间服务器的IP地址

stratum

表示相应系统时钟的层数

offset

表示相对上一级参考时钟的偏移量,单位为毫秒

synch distance

表示相对上一级时钟源的同步距离,单位为秒

refid

主参考时钟源的标识,主参考时钟的层数为0时,显示为LOCL;为其他值时,显示为主参考时钟的IP地址

 

1.1.4  ntp-service access

【命令】

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服务的访问控制权限从高到低依次为peerserversynchronizationquery。当本地NTP服务器收到一个访问请求时,将按照从高到低的顺序依次匹配。

ntp-service access命令提供了一种最小限度的安全措施,更安全的方法是进行身份验证。相关配置,可以参考命令ntp-service authentication enable

【举例】

# 设置允许第2076号访问列表中的远程设备对本地交换机的NTP服务具有对等体权限。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] ntp-service access peer 2076

# 设置第2028号访问列表中的远程设备对本地交换机的NTP服务具有服务器权限。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] ntp-service access server 2028

1.1.5  ntp-service authentication enable

【命令】

ntp-service authentication enable

undo ntp-service authentication enable

【视图】

系统视图

【参数】

【描述】

ntp-service authentication enable命令用来开启NTP身份验证功能。undo ntp-service authentication enable命令用来关闭NTP身份验证功能。

缺省情况下,NTP身份验证功能处于关闭状态。

相关配置,可以参考命令ntp-service reliable authentication-keyid、ntp-service authentication-keyid

【举例】

# 开启NTP身份验证功能。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] ntp-service authentication enable

1.1.6  ntp-service authentication-keyid

【命令】

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的密钥验证算法。

密钥配置完成后,用户还需要通过ntp-service reliable authentication-keyid命令将指定编号的密钥配置为可信密钥。相关命令,请参考ntp-service reliable authentication-keyid

【举例】

# 设置MD5身份验证密钥,密钥ID号为10,密钥为BetterKey。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] ntp-service authentication enable

[Sysname] ntp-service authentication-keyid 10 authentication-mode md5 BetterKey

1.1.7  ntp-service broadcast-client

【命令】

ntp-service broadcast-client

undo ntp-service broadcast-client

【视图】

VLAN接口视图

【参数】

【描述】

ntp-service broadcast-client命令用来配置以太网交换机工作在NTP广播客户端模式,并使用当前接口接收NTP广播消息。undo ntp-service broadcast-client命令用来取消NTP广播客户端模式配置。

缺省情况下,系统没有配置交换机的NTP工作模式。

【举例】

# 配置交换机工作在广播客户端模式,并在Vlan-interface1接口上接收NTP广播消息。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] interface Vlan-interface1

[Sysname-Vlan-interface1] ntp-service broadcast-client

1.1.8  ntp-service broadcast-server

【命令】

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。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] interface Vlan-interface 1

[Sysname-Vlan-interface1] ntp-service broadcast-server authentication-key 4 version 3

1.1.9  ntp-service in-interface disable

【命令】

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报文。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] interface Vlan-interface 1

[Sysname-Vlan-interface1] ntp-service in-interface disable

1.1.10  ntp-service max-dynamic-sessions

【命令】

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个。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] ntp-service max-dynamic-sessions 50

1.1.11  ntp-service multicast-client

【命令】

ntp-service multicast-client [ ip-address ]

undo ntp-service multicast-client [ ip-address ]

【视图】

VLAN接口视图

【参数】

ip-address:组播IP地址,范围为224.0.1.0~239.255.255.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。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] interface Vlan-interface 1

[Sysname-Vlan-interface1] ntp-service multicast-client 224.0.1.2

1.1.12  ntp-service multicast-server

【命令】

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~239.255.255.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。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] interface Vlan-interface 1

[Sysname-Vlan-interface1]ntp-service multicast-server 224.0.1.2

authentication-keyid 4 version 3

1.1.13  ntp-service reliable authentication-keyid

【命令】

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-service authentication-keyid

【举例】

# 设置启用NTP身份验证,采用MD5加密方法,密钥ID号为37,密钥为BetterKey。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] ntp-service authentication enable

[Sysname] ntp-service authentication-keyid 37 authentication-mode md5 BetterKey

# 配置该密钥为可信密钥。

[Sysname] ntp-service reliable authentication-keyid 37

1.1.14  ntp-service source-interface

【命令】

ntp-service source-interface Vlan-interface vlan-id

undo ntp-service source-interface

【视图】

系统视图

【参数】

Vlan-interface vlan-id:指定接口,使用其IP地址作为发出的NTP报文中的源IP地址。vlan-id表示指定VLAN接口的编号,取值范围1~4094。

【描述】

ntp-service source-interface命令用来指定本地发送NTP报文的接口。undo ntp-service source-interface命令用来取消当前配置。

当不想本地交换机上其它接口的IP地址成为应答消息的目的地址时,可以使用该命令指定一个特定接口来发送所有的NTP消息包。此时消息包中的源IP地址都用该接口的IP地址。

【举例】

# 指定NTP所有输出消息包的源IP地址都用VLAN-interface1的IP地址。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] ntp-service source-interface Vlan-interface 1

1.1.15  ntp-service unicast-peer

【命令】

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工作模式。

remote-ippeer-name所指定的远程设备作为本地以太网交换机的对等体,本地交换机运行在主动对等体模式。此时,本地交换机的时钟可以同步到远程设备,而远程设备的时钟也能同步到本地交换机。

 

【举例】

# 本地交换机被配置成由peer 128.108.22.44提供同步时间,本地对等体也能为peer提供同步时间,版本号为3。NTP消息包的IP地址从Vlan-interface1获得。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] ntp-service unicast-peer 128.108.22.44 version 3 source-interface Vlan-interface 1

1.1.16  ntp-service unicast-server

【命令】

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。缺省时,启用身份验证。

priorityremote-ipserver-name所指定的服务器为优先选择的服务器。

source-interface Vlan-interface vlan-id:指定一个接口。本地交换机给服务器发送NTP消息时,消息包中的源IP地址为该接口的IP地址。vlan-id为VLAN接口的编号。

version number:指定NTP版本号。number的取值范围为1~3,缺省值为3。

【描述】

ntp-service unicast-server命令用来配置以太网交换机工作在NTP客户端模式。undo ntp-service unicast-server命令用来取消NTP客户端模式的配置。

缺省情况下,系统没有配置交换机的NTP工作模式。

remote-ipserver-name所指定的远程设备作为NTP时间服务器,本地以太网交换机作为客户端。此时,客户端的时钟将以NTP服务器的时间为准进行同步,而NTP服务器的时钟不会被客户端的时钟同步。

 

【举例】

# 配置本地交换机由NTP服务器128.108.22.44提供同步时间,版本号为3。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname] ntp-service unicast-server 128.108.22.44 version 3

 

不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!

新华三官网
联系我们