配置带验证的NTP广播模式示例
在局域网中,指定时钟精度高的设备作为NTP服务器,其他的设备同步服务器的时钟。在广播模式下,用户不需要为客户端指定服务器,客户端只要实时侦听广播服务器发送的报文即可。
组网需求
如图5-3所示。
DeviceC和DeviceD在同一个网段,DeviceA在另一个网段。DeviceF连接这两个网段。
DeviceC作为NTP广播服务器,使用本地时钟作为NTP主时钟,层数为3,从接口GE0/1/0向外发送广播消息包。
DeviceD和DeviceA分别从各自的接口GE0/1/0侦听广播消息。
DeviceA、DeviceB、DeviceC和DeviceD上启用NTP验证。
本例中interface1和interface2分别代表GE0/1/0和0/2/0。
操作步骤
- 配置各路由器的IP地址
按图5-3配置各接口的IP地址。具体过程略。
- 配置NTP广播服务器,并启用验证
# 配置DeviceC使用本地时钟作为NTP主时钟,层数为3。
<DeviceC> system-view
[~DeviceC] ntp-service refclock-master 3
# 启用NTP验证。
[*DeviceC] ntp-service authentication enable
[*DeviceC] ntp-service authentication-keyid 16 authentication-mode md5 Hello123
[*DeviceC] ntp-service reliable authentication-keyid 16
# 配置DeviceC为NTP广播服务器,从接口GE0/1/0发送NTP广播消息包,并指定使用密钥ID 16加密。
[*DeviceC] interface gigabitethernet 0/1/0
[*DeviceC-GigabitEthernet0/1/0] ntp-service broadcast-server authentication-keyid 16
[*DeviceC-GigabitEthernet0/1/0] commit
[~DeviceC-GigabitEthernet0/1/0] quit
- 配置与服务器在同一网段的NTP广播客户端DeviceD
# 启用NTP验证。
<DeviceD> system-view
[~DeviceD] ntp-service authentication enable
[*DeviceD] ntp-service authentication-keyid 16 authentication-mode md5 Hello123
[*DeviceD] ntp-service reliable authentication-keyid 16
# 配置DeviceD为NTP广播客户端,从接口GE0/1/0侦听NTP广播消息包。
[*DeviceD] interface gigabitethernet 0/1/0
[*DeviceD-GigabitEthernet0/1/0] ntp-service broadcast-client
[*DeviceD-GigabitEthernet0/1/0] commit
[~DeviceD-GigabitEthernet0/1/0] quit
配置完成后,DeviceD的时钟同步到DeviceC。
- 配置与服务器在不同网段的NTP广播客户端DeviceA
# 启用NTP验证。
[*DeviceA] ntp-service authentication enable
[*DeviceA] ntp-service authentication-keyid 16 authentication-mode md5 Hello123
[*DeviceA] ntp-service reliable authentication-keyid 16
# 配置DeviceA为NTP广播客户端,从接口GE0/1/0侦听NTP广播消息包。
[*DeviceA] interface gigabitethernet 0/1/0
[*DeviceA-GigabitEthernet0/1/0] ntp-service broadcast-client
[*DeviceA-GigabitEthernet0/1/0] commit
[~DeviceA-GigabitEthernet0/1/0] quit
- 验证配置结果
完成以上配置后,DeviceD能够同步到DeviceC,而DeviceA不能同步到DeviceC。
这是因为DeviceA和DeviceC不在同一个网段,收不到DeviceC发出的广播包;而DeviceD和DeviceC在同一个网段,能够收到DeviceC发出的广播包。
查看DeviceD的NTP状态,可以看到时钟状态为“synchronized”,即,已经完成同步。时钟的层数为4,比服务器DeviceC低1级。
[~DeviceD] display ntp-service status
clock status: synchronized
clock stratum: 4
reference clock ID: 3.0.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 2006(C7B7F851.C5EAF25B)
synchronization state: clock synchronized
配置文件
DeviceA的配置文件
#
sysname DeviceA
#
ntp-service authentication-keyid 16 authentication-mode md5 cipher %#%#JA!v6M22=Gg\{>U.lx%#)c%yY}0*"/`5mi><QS)L%#%#
ntp-service reliable authentication-keyid 16
ntp-service authentication enable
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 1.0.1.11 255.255.255.0
ntp-service broadcast-client
#
ospf 1
area 0.0.0.0
network 1.0.1.0 0.0.0.255
#
return
DeviceC的配置文件
#
sysname DeviceC
#
ntp-service authentication-keyid 16 authentication-mode md5 cipher %#%#>hD8))_H-XZVut2u3!_0lq3,+Ph=:OE}pX;T2M'9%#%#
ntp-service reliable authentication-keyid 16
ntp-service refclock-master 3
ntp-service authentication enable
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 3.0.1.31 255.255.255.0
ntp-service broadcast-server authentication-keyid 16
#
return
DeviceD的配置文件
#
sysname DeviceD
#
ntp-service authentication-keyid 16 authentication-mode md5 cipher %#%#m:fVJfk*r&3x"1J`21^K`Y;LH;B+g(t2<ZX^}Q_~%#%#
ntp-service reliable authentication-keyid 16
ntp-service authentication enable
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 3.0.1.32 255.255.255.0
ntp-service broadcast-client
#
Return
DeviceF的配置文件
#
sysname DeviceF
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 1.0.1.2 255.255.255.0
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 3.0.1.2 255.255.255.0
#
ospf 1
area 0.0.0.0
network 1.0.1.0 0.0.0.255
network 3.0.1.0 0.0.0.255
#
return