组网图形
组网需求
如图1所示的组网中,SwitchA、SwitchB和SwitchC相连。SwitchA的时间已经同步到权威时钟(卫星定位系统)。
用户要求由SwitchB和SwitchC时间同步到SwitchA以保证计费业务的准确性。
配置思路
配置带验证的单播服务器/客户端模式来满足客户对局域网时间同步的需求。配置思路如下:
在单播服务器/客户端模式下配置NTP认证时,必须首先在客户端使能NTP认证,然后再指定NTP服务器地址,并同时指定发给服务器的验证密钥。否则将不进行验证,直接同步。 操作步骤
配置SwitchA、SwitchB和SwitchC地址,保证SwitchA,SwitchB和SwitchC路由可达
# 在SwitchA上配置IP地址和路由。 <HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan 100 [SwitchA-vlan100] quit [SwitchA] interface vlanif 100 [SwitchA-Vlanif100] ip address 10.1.1.1 24 [SwitchA-Vlanif100] quit [SwitchA] interface gigabitethernet 1/0/1 [SwitchA-GigabitEthernet1/0/1] port link-type trunk [SwitchA-GigabitEthernet1/0/1] port trunk allow-pass vlan 100 [SwitchA-GigabitEthernet1/0/1] quit [SwitchA] ip route-static 10.1.2.0 24 10.1.1.2 # 在SwitchB上配置IP地址。 <HUAWEI> system-view [HUAWEI] sysname SwitchB [SwitchB] vlan 100 [SwitchB-vlan100] quit [SwitchB] interface vlanif 100 [SwitchB-Vlanif100] ip address 10.1.1.2 24 [SwitchB-Vlanif100] quit [SwitchB] vlan 10 [SwitchB-vlan10] quit [SwitchB] interface vlanif 10 [SwitchB-Vlanif10] ip address 10.1.2.1 24 [SwitchB-Vlanif10] quit [SwitchB] interface gigabitethernet 1/0/1 [SwitchB-GigabitEthernet1/0/1] port link-type trunk [SwitchB-GigabitEthernet1/0/1] port trunk allow-pass vlan 100 [SwitchB-GigabitEthernet1/0/1] quit [SwitchB] interface gigabitethernet 1/0/2 [SwitchB-GigabitEthernet1/0/2] port link-type trunk [SwitchB-GigabitEthernet1/0/2] port trunk allow-pass vlan 10 [SwitchB-GigabitEthernet1/0/2] quit # 在SwitchC上配置IP地址和路由。 <HUAWEI> system-view [HUAWEI] sysname SwitchC [SwitchC] vlan 10 [SwitchC-vlan10] quit [SwitchC] interface vlanif 10 [SwitchC-Vlanif10] ip address 10.1.2.2 24 [SwitchC-Vlanif10] quit [SwitchC] interface gigabitethernet 1/0/1 [SwitchC-GigabitEthernet1/0/1] port link-type trunk [SwitchC-GigabitEthernet1/0/1] port trunk allow-pass vlan 10 [SwitchC-GigabitEthernet1/0/1] quit [SwitchC] ip route-static 10.1.1.0 24 10.1.2.1 在SwitchA上配置NTP主时钟并启动NTP认证功能
# 在SwitchA上指定使用自己的本地时钟作为主时钟,层数为2。 [SwitchA] ntp-service refclock-master 2 # 使能NTP认证功能、配置验证密钥并声明该密钥可信。 [SwitchA] ntp-service authentication enable [SwitchA] ntp-service authentication-keyid 42 authentication-mode hmac-sha256 cipher Hello123 [SwitchA] ntp-service reliable authentication-keyid 42 # SwitchA作为服务器需要使能NTP服务器功能。 [SwitchA] undo ntp-service server disable 在SwitchB上使能NTP认证功能并配置验证密钥并声明该密钥可信,指定SwitchA作为NTP服务器
[SwitchB] ntp-service authentication enable [SwitchB] ntp-service authentication-keyid 42 authentication-mode hmac-sha256 cipher Hello123 [SwitchB] ntp-service reliable authentication-keyid 42 [SwitchB] ntp-service unicast-server 10.1.1.1 authentication-keyid 42 在SwitchC上使能NTP认证功能并配置验证密钥并声明该密钥可信,指定SwitchA作为NTP服务器
[SwitchC] ntp-service authentication enable [SwitchC] ntp-service authentication-keyid 42 authentication-mode hmac-sha256 cipher Hello123 [SwitchC] ntp-service reliable authentication-keyid 42 [SwitchC] ntp-service unicast-server 10.1.1.1 authentication-keyid 42 验证配置结果
# 查看SwitchA的NTP状态。 [SwitchA] display ntp-service status clock status: synchronized clock stratum: 2 reference clock ID: LOCAL(0) nominal frequency: 100.0000 Hz actual frequency: 100.0000 Hz clock precision: 2^17 clock offset: 0.0000 ms root delay: 0.00 ms root dispersion: 10.96 ms peer dispersion: 10.00 ms reference time: 08:54:40.010 UTC Nov 22 2013(D6399696.029E9079) synchronization state: clock synchronized # 查看SwitchB的NTP状态,可以看到时钟状态为“synchronized”,即,已经完成同步。时钟的层数为3,比服务器SwitchA低1级。 [SwitchB] display ntp-service status clock status: synchronized clock stratum: 3 reference clock ID: 10.1.1.1 nominal frequency: 100.0000 Hz actual frequency: 100.0000 Hz clock precision: 2^18 clock offset: -1.6796 ms root delay: 2.71 ms root dispersion: 21.87 ms peer dispersion: 10.94 ms reference time: 08:54:44.160 UTC Nov 22 2013(D6399A54.29247CB7) synchronization state: clock synchronized # 查看SwitchC的NTP状态,可以看到时钟状态为“synchronized”,即,已经完成同步。时钟的层数为3,比服务器SwitchA低1级。 [SwitchC] display ntp-service status clock status: synchronized clock stratum: 3 reference clock ID: 10.1.1.1 nominal frequency: 100.0000 Hz actual frequency: 100.0000 Hz clock precision: 2^18 clock offset: 13.6320 ms root delay: 2.71 ms root dispersion: 2.76 ms peer dispersion: 10.94 ms reference time: 08:57:44.160 UTC Nov 22 2013(D6399E4E.052B2BFD) synchronization state: clock synchronized |