配置带验证的NTP广播模式示例
组网需求
如图4-13所示的组网中,RouterF、RouterC和RouterD在同一个局域网中。RouterA和RouterF直连。RouterC通过无线电直接同步到标准时钟。
用户由于业务需要,要求局域网中的所有工业路由交换一体机的时间同步到标准时钟,但是不影响RouterA的系统时钟。
配置思路
根据用户需求,采用NTP协议实现时钟同步,配置思路如下:
选择RouterC作为主时钟服务器,使用本地时钟作为NTP主时钟,层数为3。
配置RouterC为NTP广播服务器,从接口GE1/0/0向外发送广播报文。
配置RouterA、RouterD和RouterF为NTP广播客户端。RouterA使用GE1/0/0接口侦听广播报文。RouterD使用GE1/0/0接口侦听广播报文。RouterF使用GE2/0/0接口侦听广播报文。
为加强网络安全,使能NTP认证功能。
操作步骤
- 按图4-13配置各接口的IP地址并配置Router之间路由可达
# 在RouterA上配置接口IP地址并配置路由协议。
<Huawei> system-view [Huawei] sysname RouterA [RouterA] interface gigabitethernet 1/0/0 [RouterA-GigabitEthernet1/0/0] undo portswitch [RouterA-GigabitEthernet1/0/0] ip address 10.1.1.11 24 [RouterA-GigabitEthernet1/0/0] quit [RouterA] ospf 1 [RouterA-ospf-1] area 0 [RouterA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255 [RouterA-ospf-1-area-0.0.0.0] quit [RouterA-ospf-1] quit
RouterC、RouterD和RouterF的配置请参考配置文件。
- 配置NTP广播服务器,并启用验证
# 配置RouterC使用本地时钟作为NTP主时钟,层数为3。
<RouterC> system-view [RouterC] ntp-service refclock-master 3
# 启用NTP认证。[RouterC] ntp-service authentication enable [RouterC] ntp-service authentication-keyid 16 authentication-mode hmac-sha256 Hello1 [RouterC] ntp-service reliable authentication-keyid 16
# 配置RouterC为NTP广播服务器,从接口GE1/0/0发送NTP广播报文,并指定使用密钥ID 16加密。[RouterC] interface gigabitethernet 1/0/0 [RouterC-GigabitEthernet1/0/0] ntp-service broadcast-server authentication-keyid 16 [RouterC-GigabitEthernet1/0/0] quit
- 配置与服务器在同一网段的NTP广播客户端RouterD
# 启用NTP认证。
<RouterD> system-view [RouterD] ntp-service authentication enable [RouterD] ntp-service authentication-keyid 16 authentication-mode hmac-sha256 Hello1 [RouterD] ntp-service reliable authentication-keyid 16
# 配置RouterD为NTP广播客户端,从接口GE1/0/0侦听NTP广播报文。[RouterD] interface gigabitethernet 1/0/0 [RouterD-GigabitEthernet1/0/0] ntp-service broadcast-client [RouterD-GigabitEthernet1/0/0] quit
配置完成后,RouterD的时钟同步到RouterC。RouterF的配置和RouterC类似,请参考配置文件。
- 配置与服务器在不同网段的NTP广播客户端RouterA
# 启用NTP认证。
[RouterA] ntp-service authentication enable [RouterA] ntp-service authentication-keyid 16 authentication-mode hmac-sha256 Hello1 [RouterA] ntp-service reliable authentication-keyid 16
# 配置RouterA为NTP广播客户端,从接口GE1/0/0侦听NTP广播报文。[RouterA] interface gigabitethernet 1/0/0 [RouterA-GigabitEthernet1/0/0] ntp-service broadcast-client [RouterA-GigabitEthernet1/0/0] quit
- 验证配置结果
完成以上配置后,RouterD能够同步到RouterC,而RouterA不能同步到RouterC。
这是因为RouterA和RouterC不在同一个网段,收不到RouterC发出的广播包;而RouterD和RouterC在同一个网段,能够收到RouterC发出的广播包。
# 查看RouterD的NTP状态,可以看到时钟状态为“synchronized”,即,已经完成同步。时钟的层数为4,比服务器RouterC低1级。
[RouterD] display ntp-service status clock status: synchronized clock stratum: 4 reference clock ID: 10.3.1.31 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.42 ms peer dispersion: 0.00 ms reference time: 12:17:21.773 UTC Mar 7 2012(C7B7F851.C5EAF25B)
配置文件
RouterA的配置文件
# sysname RouterA # interface GigabitEthernet1/0/0 undo portswitch ip address 10.1.1.11 255.255.255.0 ntp-service broadcast-client # ntp-service authentication enable ntp-service authentication-keyid 16 authentication-mode hmac-sha256 cipher %@%@,1_MBtq@`IsY6$XkI|J<"6P(%@%@ ntp-service reliable authentication-keyid 16 # return
RouterC的配置文件
# sysname RouterC # interface GigabitEthernet1/0/0 undo portswitch ip address 10.3.1.31 255.255.255.0 ntp-service broadcast-server authentication-keyid 16 # ntp-service authentication enable ntp-service authentication-keyid 16 authentication-mode hmac-sha256 cipher %@%@,1_MBtq@`IsY6$XkI|J<"6P(%@%@ ntp-service reliable authentication-keyid 16 ntp-service refclock-master 3 # return
RouterD的配置文件
# sysname RouterD # interface GigabitEthernet1/0/0 undo portswitch ip address 10.3.1.31 255.255.255.0 ntp-service broadcast-client # ntp-service authentication enable ntp-service authentication-keyid 16 authentication-mode hmac-sha256 cipher %@%@,1_MBtq@`IsY6$XkI|J<"6P(%@%@ ntp-service reliable authentication-keyid 16 # return
RouterF的配置文件
# sysname RouterF # interface GigabitEthernet1/0/0 undo portswitch ip address 10.1.1.2 255.255.255.0 # interface GigabitEthernet2/0/0 undo portswitch ip address 10.3.1.2 255.255.255.0 ntp-service broadcast-client # ntp-service authentication enable ntp-service authentication-keyid 16 authentication-mode hmac-sha256 cipher %@%@,1_MBtq@`IsY6$XkI|J<"6P(%@%@ ntp-service reliable authentication-keyid 16 # return