您好,欢迎访问这里是深圳市硕远科技有限公司!
戴尔服务器价格_IBM联想配置_浪潮代理-深圳市硕远科技有限公司
联系我们
戴尔服务器价格_IBM联想配置_浪潮代理-深圳市硕远科技有限公司
邮箱:2324898850@qq.com
电话:400-080-6079
地址:深圳市龙华区河背工业区108创业园A301
当前位置:主页 > 新闻动态 > 企业新闻 >

企业新闻

华为NTP配置教程(一)

发布时间:2023-01-12 13:03:08浏览次数:

1、配置NTP主时钟

网络中的设备可以通过以下两种方式进行时钟同步:与本地时钟进行同步:即采用本地时钟作为参考时钟。与网络中的其他设备进行同步:即采用其他设备作为NTP时钟服务器为本地提供参考时钟。

如果同时配置了两种方式,设备将通过时钟优选来选择最优的时钟源,即比较两者的层数,层数低者为优选时钟源。

权威时钟作为同步子网的基准时间参考源,位于同步子网的最顶端,层数为0。目前权威时钟通常是Radio Clock或卫星定位系统等。权威时钟通过播发的UTC时间代码而非通过NTP进行时间同步。

实际网络中,通常将从权威时钟获得时钟同步的NTP服务器的层数设置为1,并将其作为主参考时钟源同步网络中其他设备的时钟,即在设备上配置本地时钟作为NTP主时钟。网络中的设备与主参考时钟源的NTP距离,即NTP同步链上NTP服务器的数目,决定了设备上时钟的层数。

配置本地时钟作为参考时钟后,本地设备可以作为时钟源同步网络中的其他设备。请谨慎使用本配置,以免导致网络中设备的时钟错误。

1、配置本地时钟作为NTP主时钟

[Huawei]ntp-service refclock-master ?

INTEGER<1-15> Stratum number

X.X.X.X IP address of the local clock 127.127.1.<0-3>

<cr>

[Huawei]ntp-service refclock-master 1

2、如果为其他设备提供时钟同步服务,可以配置同步端口号

[HUAWEI] ntp-service port 5000

2、配置NTP工作模式

设备支持如下几种NTP工作模式:

如果在服务器端指定了发送NTP报文的源地址,该地址必须与在客户端配置的服务器IP地址相同。否则,客户端无法处理服务器端发送的NTP报文,进而时钟同步失败。

1、单播客户端/服务器模式

单播客户端/服务器模式只需要在客户端配置,服务器端除了配置NTP主时钟外,不需要进行其他专门配置。

只有当服务器时钟被同步后,才能作为时钟服务器去同步其他设备。当服务器端的时钟层数大于或等于客户端的时钟层数时,客户端将不会向其同步。

可以通过多次执行ntp-service unicast-server命令配置多个服务器,客户端依据时钟优选来选择最优的时钟源。

[Huawei]ntp-service unicast-server ?

X.X.X.X IP address

ipv6 NTP IPv6 service

[Huawei]ntp-service unicast-server 10.1.1.2 ?

authentication-keyid Specify NTP authentication key identifier

autokey Enable autokey

burst Send a burst when server is reachable

iburst Send a burst when server is unreachable

maxpoll Maximum poll interval for sending packets

minpoll Minimum poll interval for sending packets

preempt Designate as preemptive

preference Prefer this source whenever possible

source-interface Specify interface whose address should be used as

source

version Specify NTP version

vpn-instance VPN instance

<cr>

[Huawei]ntp-service unicast-server 10.1.1.2 version ?

INTEGER<1-4> NTP version number

[Huawei]ntp-service unicast-server 10.1.1.2 version 3 ?

authentication-keyid Specify NTP authentication key identifier

autokey Enable autokey

burst Send a burst when server is reachable

iburst Send a burst when server is unreachable

maxpoll Maximum poll interval for sending packets # NTP最大轮询间隔

minpoll Minimum poll interval for sending packets # NTP最小轮询间隔

preempt Designate as preemptive

preference Prefer this source whenever possible # 指定该远端对等体为优先选择的对等体

source-interface Specify interface whose address should be used as ource

vpn-instance VPN instance

<cr>

2、对等体模式

用户只需要在主动对等体端指定被动对等体的IP地址,对等体之间使用此IP地址交换NTP报文。主、被动对等体中至少有一个处于同步状态,否则他们都将无法同步。

[Huawei]ntp-service unicast-peer ?

X.X.X.X IP address

ipv6 NTP IPv6 service

[Huawei]ntp-service unicast-peer 10.1.1.1 ?

authentication-keyid Specify NTP authentication key identifier

autokey Enable autokey

maxpoll Maximum poll interval for sending packets

minpoll Minimum poll interval for sending packets

preempt Designate as preemptive

preference Prefer this source whenever possible

source-interface Specify interface whose address should be used as

source

version Specify NTP version

vpn-instance VPN instance

<cr>

[Huawei]ntp-service unicast-peer 10.1.1.1 version ?

INTEGER<1-4> NTP version number

[Huawei]ntp-service unicast-peer 10.1.1.1 version 3 ?

authentication-keyid Specify NTP authentication key identifier

autokey Enable autokey

maxpoll Maximum poll interval for sending packets

minpoll Minimum poll interval for sending packets

preempt Designate as preemptive

preference Prefer this source whenever possible

source-interface Specify interface whose address should be used as source

vpn-instance VPN instance

<cr>

3、广播模式

广播模式只能在同一局域网中使用。广播服务器只有当其时钟同步后,才能去同步广播客户端。

3.1、配置本地设备作为NTP广播服务器

[Huawei-GigabitEthernet0/0/2]ntp-service broadcast-server ?

authentication-keyid Specify broadcast authentication keyid

version Specify NTP version

<cr> Please press ENTER to execute command

3.2、配置本地设备为NTP广播客户端

[Huawei-GigabitEthernet0/0/6]ntp-service broadcast-client

4、组播模式

组播服务器只有当其时钟同步后,才能去同步组播客户端。华为设备上最多可配置128个组播服务器。目前最多可以配置1024个组播客户端,但同时起作用的最多为128个。

4.1、配置本地设备作为组播服务器

[Huawei-GigabitEthernet0/0/1]ntp-service multicast-server ?

IP_ADDR<X.X.X.X> IP address

authentication-keyid Specify authentication keyid

ttl Specify TTL value of multicast packet

version Specify NTP version

<cr> Please press ENTER to execute command

4.2、配置本地设备作为组播客户端

[Huawei-GigabitEthernet0/0/1]ntp-service multicast-client ?

IP_ADDR<X.X.X.X>

<cr> Please press ENTER to execute command

5、多播模式

5.1、配置本地设备作为多播服务器

播服务器回应客户端发送的多播报文。在收到回应报文以后,多播客户端与服务器建立短暂的关联并进入C/S模式。如果在执行undo ntp-service manycast-server命令时没有指定组播IP地址,本地设备查找缺省的IP地址。在IPv4网络中,组播服务器的缺省IP地址为224.0.1.1;在IPv6网络中,组播服务器的缺省IP地址为FF0E::0101。如果本地设备查找到了缺省的IP地址,undo ntp-service manycast-server生效;否则undo ntp-service manycast-server命令不生效。

[HUAWEI-Vlanif100] ntp-service manycast-server

5.2、配置本地设备作为多播客户端

地设备运行在多播客户端模式,并且周期性的向多播服务器发送多播报文。在收到多播服务器发送的回应报文后,本地设备与服务器建立动态C/S关联。配置多播客户端时,若不指定服务器地址,则默认采用224.0.1.1或FF0E::0101作为服务器地址。

[HUAWEI-Vlanif100] ntp-service manycast-client

3、配置NTP客户端时钟更新间隔

当服务器的时钟发生变化时,客户端的时钟需要与服务器的时钟进行同步。

[Huawei]ntp-service sync-interval ?

INTEGER<180-600> Synchronization time interval in seconds

4、配置发送/接收NTP报文的本地源接口

配置发送/接收NTP报文的本地源接口,可避免本设备上其他接口的IP地址成为应答报文的目的地址,便于用户后续部署流量控制策略。

缺省情况下,没有指定本地发送NTP报文源接口,即根据路由选择NTP报文的源IP地址。

对于广播、组播方式和多播模式,NTP服务是在特定的接口下进行的,源接口就是该接口。因此,ntp-service source-interface命令不生效。如果指定的NTP源接口处于Down状态,则发送的NTP报文源IP地址为该报文出接口的主IP地址。

[Huawei]ntp-service source-interface ?

Ethernet Ethernet interface

GigabitEthernet GigabitEthernet interface

NULL NULL interface

Serial Serial interface

5、限制NTP本地动态会话数

过多的动态会话直接影响静态会话的建立,用户可通过限制本地动态会话数来解决这一问题。单播客户端/服务器模式和对等体模式都是通过命令行建立连接,属于静态会话。广播模式、多播模式和组播模式建立的是动态会话,所以限制本地动态会话数能够生效。

[Huawei]ntp-service max-dynamic-sessions ?

INTEGER<0-100> Number of NTP sessions

6、禁止指定接口接收NTP报文

当设备存在如下场景时,可在与外部设备相连的接口执行本命令来禁止接口接收NTP报文:

该接口下存在不可靠时钟服务器。在使能NTP功能后,缺省情况下所有接口都可以接收NTP报文,但是如果存在不可靠时钟源,可造成NTP时钟数据不准确。该接口受到恶意攻击导致NTP时钟数据遭到篡改。

[Huawei-GigabitEthernet0/0/2]ntp-service in-interface disable

7、关闭NTP服务功能

为了防止设备与外部服务器或对等体的时钟进行同步,或者该设备无需向外部客户端提供参考时钟源,可以关闭NTP的服务功能。关闭NTP服务不会删除已有配置。

1、关闭NTP功能

[Huawei]ntp-service disable

2、关闭NTP服务器功能

[Huawei]ntp-service server disable

8、配置NTP访问控制权限

NTP访问控制实现一种简单的安全措施。当有一个访问请求时,按照最大访问限制到最小访问限制依次匹配,以第一个匹配的为准,匹配顺序为peer、server、synchronization、query、limited。

peer: 远端设备可以给本地设备发送时间请求和控制查询,本地时钟也可以同步到远端服务器。

server: 远端设备可以给本地设备发送时间请求和控制查询,但本地时钟不会同步到远端服务器。

synchronization: 只允许远端设备对本地设备提出时间请求。

query: 只允许远端设备对本地设备进行控制查询。

limited: 当NTP报文速率高于上限时,丢弃入方向的NTP报文。

配置NTP服务的访问控制权限前,请先检查ACL规则的配置情况。当ACL规则配置为permit时,则允许匹配该规则中指定源IP地址的对端设备在访问本地设备NTP服务时具有使用ntp-service access命令配置的访问控制权限;而ACL规则配置为deny时,则拒绝匹配该规则中指定源IP地址的对端设备访问本地设备NTP服务。

[Huawei]ntp-service access ?

limited Enable rate limiting of incoming NTP packets and sending of RATE kiss code when Kiss-O'-Death is enabled

peer Enable full access

query Enable query access

server Enable server and query access

synchronization Enable server access only

9、配置发送NTP报文的最小时间间隔和平均时间间隔

[Huawei]ntp-service discard avg-interval ?

INTEGER<1-8> Seconds expressed as a power of 2

[Huawei]ntp-service discard min-interval ?

INTEGER<1-8> Seconds expressed as a power of 2

400-080-6079