组网图形
IPv4静态路由与NQA联动简介
组网需求
配置思路
操作步骤
# 配置SwitchA。SwitchB、SwitchC、SwitchD和SwitchE的配置与SwitchA类似,不再赘述。
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 30 40 [SwitchA] interface gigabitethernet 0/0/1 [SwitchA-GigabitEthernet0/0/1] port link-type trunk [SwitchA-GigabitEthernet0/0/1] port trunk allow-pass vlan 30 [SwitchA-GigabitEthernet0/0/1] quit [SwitchA] interface gigabitethernet 0/0/2 [SwitchA-GigabitEthernet0/0/2] port link-type trunk [SwitchA-GigabitEthernet0/0/2] port trunk allow-pass vlan 40 [SwitchA-GigabitEthernet0/0/2] quit
# 配置SwitchA。SwitchB、SwitchC、SwitchD和SwitchE的配置与SwitchA类似,不再赘述。
[SwitchA] interface vlanif 30 [SwitchA-Vlanif30] ip address 192.168.3.1 24 [SwitchA-Vlanif30] quit [SwitchA] interface vlanif 40 [SwitchA-Vlanif40] ip address 192.168.4.1 24 [SwitchA-Vlanif40] quit
[SwitchB] nqa test-instance user test //创建管理者为user,实例名为test的NQA测试例 [SwitchB-nqa-user-test] test-type icmp //配置NQA测试例的测试类型为ICMP [SwitchB-nqa-user-test] destination-address ipv4 192.168.1.2 //配置NQA测试例的目的地址为192.168.1.2 [SwitchB-nqa-user-test] frequency 20 //配置NQA测试例自动执行测试的时间间隔为20秒 [SwitchB-nqa-user-test] probe-count 2 //配置NQA测试例的一次测试探针数目为2 [SwitchB-nqa-user-test] interval seconds 5 //配置NQA测试例的发送报文的时间间隔为5秒 [SwitchB-nqa-user-test] timeout 4 //配置NQA测试例的一次探测的超时时间为4秒 [SwitchB-nqa-user-test] start now [SwitchB-nqa-user-test] quit
# 在SwitchB上配置与NQA测试例联动的静态路由。
[SwitchB] ip route-static 192.168.7.0 255.255.255.0 Vlanif 10 192.168.1.2 track nqa user test
# 在SwitchC上配置静态路由。
[SwitchC] ip route-static 192.168.7.0 255.255.255.0 Vlanif 60 192.168.6.2
# 在SwitchA上配置OSPF协议。
[SwitchA] ospf 1 router-id 10.1.1.1 [SwitchA-ospf-1] area 0.0.0.0 [SwitchA-ospf-1-area-0.0.0.0] network 192.168.3.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.0] network 192.168.4.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.0] quit [SwitchA-ospf-1] quit
# 在SwitchB上配置OSPF协议。
[SwitchB] ospf 1 router-id 10.2.2.2 [SwitchB-ospf-1] area 0.0.0.0 [SwitchB-ospf-1-area-0.0.0.0] network 192.168.3.0 0.0.0.255 [SwitchB-ospf-1-area-0.0.0.0] quit [SwitchB-ospf-1] quit
# 在SwitchC上配置OSPF协议。
[SwitchC] ospf 1 router-id 10.3.3.3 [SwitchC-ospf-1] area 0.0.0.0 [SwitchC-ospf-1-area-0.0.0.0] network 192.168.4.0 0.0.0.255 [SwitchC-ospf-1-area-0.0.0.0] quit [SwitchC-ospf-1] quit
# 在SwitchB上配置OSPF动态路由协议引入静态路由,并且把路由开销值设置为10。
[SwitchB] ospf 1 [SwitchB-ospf-1] import-route static cost 10 [SwitchB-ospf-1] quit
# 在SwitchC上配置OSPF动态路由协议引入静态路由,并且把路由开销值设置为20。
[SwitchC] ospf 1 [SwitchC-ospf-1] import-route static cost 20 [SwitchC-ospf-1] quit
配置完成后,在系统视图下,在汇聚层交换机SwitchB上执行display current-configuration | include nqa命令,可以看到静态路由已经绑定NQA测试例。执行display nqa results命令,可以看到NQA测试例已经建立。
# 查看NQA for静态路由的配置。
[SwitchB] display current-configuration | include nqa ip route-static 192.168.7.0 255.255.255.0 Vlanif10 192.168.1.2 track nqa user test nqa test-instance user test
# 查看NQA测试结果。
[SwitchB] display nqa results test-instance user test NQA entry(user, test) :testflag is active ,testtype is icmp 1 . Test 288 result The test is finished Send operation times: 2 Receive response times: 2 Completion:success RTD OverThresholds number: 0 Attempts number:1 Drop operation number:0 Disconnect operation number:0 Operation timeout number:0 System busy operation number:0 Connection fail number:0 Operation sequence errors number:0 RTT Status errors number:0 Destination ip address:192.168.1.2 Min/Max/Average Completion Time: 3/4/3 Sum/Square-Sum Completion Time: 7/25 Last Good Probe Time: 2019-09-09 09:55:38.2 Lost packet ratio: 0 %
可以看到“Lost packet ratio: 0 %”,这说明链路状态完好。
# 查看SwitchB的路由表,可以看到静态路由存在于路由表中。
[SwitchB] display ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 10 Routes : 10 Destination/Mask Proto Pre Cost Flags NextHop Interface 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.1.0/24 Direct 0 0 D 192.168.1.1 Vlanif10 192.168.1.1/32 Direct 0 0 D 127.0.0.1 Vlanif10 192.168.3.0/24 Direct 0 0 D 192.168.3.2 Vlanif30 192.168.3.2/32 Direct 0 0 D 127.0.0.1 Vlanif30 192.168.4.0/24 OSPF 10 2 D 192.168.3.1 Vlanif30 192.168.5.0/24 Direct 0 0 D 192.168.5.1 Vlanif50 192.168.5.1/32 Direct 0 0 D 127.0.0.1 Vlanif50 192.168.7.0/24 Static 60 0 D 192.168.1.2 Vlanif10
# 查看汇聚层交换机SwitchA的路由表。
[SwitchA] display ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 7 Routes : 7 Destination/Mask Proto Pre Cost Flags NextHop Interface 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.3.0/24 Direct 0 0 D 192.168.3.1 Vlanif30 192.168.3.1/32 Direct 0 0 D 127.0.0.1 Vlanif30 192.168.4.0/24 Direct 0 0 D 192.168.4.1 Vlanif40 192.168.4.1/32 Direct 0 0 D 127.0.0.1 Vlanif40 192.168.7.0/24 O_ASE 150 10 D 192.168.3.2 Vlanif30
可以看到有一条到192.168.7.0/24的路由,下一跳指向192.168.3.2,cost值为10,因此业务流量会优先走链路SwitchB→SwitchD。
# 关闭SwitchB的GigabitEthernet0/0/3 接口,模拟链路故障。
[SwitchB] interface GigabitEthernet0/0/3 [SwitchB-GigabitEthernet0/0/3] shutdown [SwitchB-GigabitEthernet0/0/3] quit
# 查看NQA测试结果。
[SwitchB] display nqa results test-instance user test NQA entry(user, test) :testflag is active ,testtype is icmp 1 . Test 309 result The test is finished Send operation times: 2 Receive response times: 0 Completion:failed RTD OverThresholds number: 0 Attempts number:1 Drop operation number:2 Disconnect operation number:0 Operation timeout number:0 System busy operation number:0 Connection fail number:0 Operation sequence errors number:0 RTT Status errors number:0 Destination ip address:192.168.1.2 Min/Max/Average Completion Time: 0/0/0 Sum/Square-Sum Completion Time: 0/0 Last Good Probe Time: 0000-00-00 00:00:00.0 Lost packet ratio: 100 %
可以看到“Completion:failed”、“Lost packet ratio: 100 %”,这说明链路发生了故障。
# 查看SwitchB的路由表,可以看到静态路由消失。
[SwitchB] display ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 8 Routes : 8 Destination/Mask Proto Pre Cost Flags NextHop Interface 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.3.0/24 Direct 0 0 D 192.168.3.2 Vlanif30 192.168.3.2/32 Direct 0 0 D 127.0.0.1 Vlanif30 192.168.4.0/24 OSPF 10 2 D 192.168.3.1 Vlanif30 192.168.5.0/24 Direct 0 0 D 192.168.5.1 Vlanif50 192.168.5.1/32 Direct 0 0 D 127.0.0.1 Vlanif50 192.168.7.0/24 O_ASE 150 20 D 192.168.3.1 Vlanif30
# 查看SwitchA的路由表。
[SwitchA] display ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 7 Routes : 7 Destination/Mask Proto Pre Cost Flags NextHop Interface 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.3.0/24 Direct 0 0 D 192.168.3.1 Vlanif30 192.168.3.1/32 Direct 0 0 D 127.0.0.1 Vlanif30 192.168.4.0/24 Direct 0 0 D 192.168.4.1 Vlanif40 192.168.4.1/32 Direct 0 0 D 127.0.0.1 Vlanif40 192.168.7.0/24 O_ASE 150 20 D 192.168.4.2 Vlanif40
因为SwitchB上的NQA测试例与静态路由是联动的,当NQA检测到链路故障后,就迅速通知SwitchB与其绑定的静态路由不可用,SwitchA也不能从SwitchB处学到通往192.168.7.0/24的路由。但是SwitchA可以从SwitchC处学到通往192.168.7.0/24的路由,因此可以看到通往192.168.7.0/24的路由下一跳指向192.168.4.2,cost值为20。业务流量切换到链路SwitchC→SwitchD。
原文:https://www.cnblogs.com/zhangwencheng/p/14116264.html