Example for Configuring NQA for IPv4 Static Routes
Networking Requirements
As shown in Figure 2-14, static routes destined for clients are configured on SwitchB and SwitchC. SwitchB is the master switch and SwitchC is the backup switch. Normally, traffic must be forwarded along the primary link SwitchB→SwitchD. If the primary link fails, traffic is switched to the backup link SwitchC→SwitchD.
Configuration Roadmap
The configuration roadmap is as follows:
- Configure IP addresses and OSPF on each switch, and configure the cost of each link so that SwitchB functions as the master switch and SwitchC functions as the backup switch.
- Create an ICMP NQA test instance to monitor the link between SwitchB and SwitchD, and configure static routes destined for clients on SwitchB SwitchC. Associate the static route with the NQA test instance to implement fast link fault detection and service switchover.
When a static route is associated with an NQA test instance, only ICMP test instances are used to test whether there are reachable routes between the source and destination.
Procedure
- Create VLANs and add interfaces to the VLANs.
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] vlan 30 [*SwitchA-vlan30] quit [*SwitchA] vlan 40 [*SwitchA-vlan40] quit [*SwitchA] interface 10ge 1/0/1 [*SwitchA-10GE1/0/1] port link-type trunk [*SwitchA-10GE1/0/1] port trunk allow-pass vlan 30 [*SwitchA-10GE1/0/1] quit [*SwitchA] interface 10ge 1/0/2 [*SwitchA-10GE1/0/2] port link-type trunk [*SwitchA-10GE1/0/2] port trunk allow-pass vlan 40 [*SwitchA-10GE1/0/2] quit [*SwitchA] commit
The configurations of SwitchB and SwitchC are similar to that of SwitchA, and are not provided here.
- Assign IPv4 addresses to the VLANIF interfaces.
[~SwitchA] interface vlanif 30 [*SwitchA-Vlanif30] ip address 172.16.3.1 24 [*SwitchA-Vlanif30] quit [*SwitchA] interface vlanif 40 [*SwitchA-Vlanif40] ip address 172.16.4.1 24 [*SwitchA-Vlanif40] quit [*SwitchA] commit
The configurations of SwitchB and SwitchC are similar to that of SwitchA, and are not provided here.
- Create an NQA test instance on SwitchB to test the link between SwitchB and SwitchD.
[~SwitchB] nqa test-instance user test
[*SwitchB-nqa-user-test] test-type icmp
[*SwitchB-nqa-user-test] destination-address ipv4 172.16.1.2
[*SwitchB-nqa-user-test] frequency 10
[*SwitchB-nqa-user-test] probe-count 2
[*SwitchB-nqa-user-test] interval seconds 5
[*SwitchB-nqa-user-test] timeout 4
[*SwitchB-nqa-user-test] start now
[*SwitchB-nqa-user-test] commit
[~SwitchB-nqa-user-test] quit
- Configure IPv4 static routes.
# Configure an IPv4 static route on SwitchB and associate it with the NQA test instance.
[~SwitchB] ip route-static 172.16.7.0 255.255.255.0 vlanif 10 172.16.1.2 track nqa user test
[*SwitchB] commit
# Configure an IPv4 static route on SwitchC.
[~SwitchC] ip route-static 172.16.7.0 255.255.255.0 vlanif 60 172.16.6.2
[*SwitchC] commit
- Configure a dynamic routing protocol on SwitchA, SwitchB, and SwitchC. OSPF is used in this example.
# Configure OSPF on SwitchA.
[~SwitchA] ospf 1
[*SwitchA-ospf-1] area 0.0.0.0
[*SwitchA-ospf-1-area-0.0.0.0] network 172.16.3.0 0.0.0.255
[*SwitchA-ospf-1-area-0.0.0.0] network 172.16.4.0 0.0.0.255
[*SwitchA-ospf-1-area-0.0.0.0] quit
[*SwitchA-ospf-1] quit
[*SwitchA] commit
# Configure OSPF on SwitchB.
[~SwitchB] ospf 1
[*SwitchB-ospf-1] area 0.0.0.0
[*SwitchB-ospf-1-area-0.0.0.0] network 172.16.3.0 0.0.0.255
[*SwitchB-ospf-1-area-0.0.0.0] quit
[*SwitchB-ospf-1] quit
[*SwitchB] commit
# Configure OSPF on SwitchC.
[~SwitchC] ospf 1
[*SwitchC-ospf-1] area 0.0.0.0
[*SwitchC-ospf-1-area-0.0.0.0] network 172.16.4.0 0.0.0.255
[*SwitchC-ospf-1-area-0.0.0.0] quit
[*SwitchC-ospf-1] quit
[*SwitchC] commit
- Configure OSPF on SwitchB and SwitchC to import static routes.
# Configure OSPF on SwitchB to import a static route, and set the cost of the static route to 10.
[~SwitchB] ospf 1
[*SwitchB-ospf-1] import-route static cost 10
[*SwitchB-ospf-1] commit
[~SwitchB-ospf-1] quit
# Configure OSPF on SwitchC to import a static route, and set the cost of the static route to 20.
[~SwitchC] ospf 1
[*SwitchC-ospf-1] import-route static cost 20
[*SwitchC-ospf-1] commit
[~SwitchC-ospf-1] quit
- Verify the configuration.
After the configuration is complete, run the display current-configuration | include nqa command in the system view on SwitchB. The command output shows that the IPv4 static route has been associated with the NQA test instance. Run the display nqa results command. The command output shows that an NQA test instance has been created.
# Display configurations of NQA for IPv4 static routes.
[~SwitchB] display current-configuration | include nqa
ip route-static 172.16.7.0 255.255.255.0 Vlanif 10 172.16.1.2 track nqa user test nqa test-instance user test
# Display the NQA test results.
[~SwitchB] display nqa results test-instance user test
NQA entry(user, test) : test flag is active ,test type is ICMP 1 . Test 6645 result The test is finished Send operation times: 2 Receive response times: 2 Completion:success RTD over thresholds 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 Stats errors number:0 Destination ip address:172.16.1.2 Min/Max/Average completion Time: 1/1/1 Sum/Square-Sum completion time: 2/2 Last response packet receiving time: 2012-11-14 04:20:36.9 Lost packet ratio: 0 %
The command output shows "Lost packet ratio 0 %", indicating that the link is running properly.
# Check the routing table on SwitchB.
[~SwitchB] display ip routing-table
Proto: Protocol Pre: Preference Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route ------------------------------------------------------------------------------ Routing Table : _public_ Destinations : 15 Routes : 15 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 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 172.16.1.0/24 Direct 0 0 D 172.16.1.1 Vlanif10 172.16.1.1/32 Direct 0 0 D 127.0.0.1 Vlanif10 172.16.1.255/32 Direct 0 0 D 127.0.0.1 Vlanif10 172.16.3.0/24 Direct 0 0 D 172.16.3.2 Vlanif30 172.16.3.2/32 Direct 0 0 D 127.0.0.1 Vlanif30 172.16.3.255/32 Direct 0 0 D 127.0.0.1 Vlanif30 172.16.4.0/24 OSPF 10 2 D 172.16.3.1 Vlanif30 172.16.5.0/24 Direct 0 0 D 172.16.5.1 Vlanif50 172.16.5.1/32 Direct 0 0 D 127.0.0.1 Vlanif50 172.16.5.255/32 Direct 0 0 D 127.0.0.1 Vlanif50 172.16.7.0/24 Static 60 0 D 172.16.1.2 Vlanif10 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
The command output shows that the static route exists in the routing table.
# Check the routing table on SwitchA.
[~SwitchA] display ip routing-table
Proto: Protocol Pre: Preference Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route ------------------------------------------------------------------------------ Routing Table : _public_ Destinations : 11 Routes : 11 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 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 172.16.3.0/24 Direct 0 0 D 172.16.3.1 Vlanif30 172.16.3.1/32 Direct 0 0 D 127.0.0.1 Vlanif30 172.16.3.255/32 Direct 0 0 D 127.0.0.1 Vlanif30 172.16.4.0/24 Direct 0 0 D 172.16.4.1 Vlanif40 172.16.4.1/32 Direct 0 0 D 127.0.0.1 Vlanif40 172.16.4.255/32 Direct 0 0 D 127.0.0.1 Vlanif40 172.16.7.0/24 O_ASE 150 10 D 172.16.3.2 Vlanif30 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
The command output shows that a route to 172.16.7.0/24 exists in the routing table. The route's next hop address is 172.16.3.2 and cost is 10. Traffic is preferentially transmitted along the link SwitchB->SwitchD.
# Shut down 10GE1/0/2 on SwitchB to simulate a link fault.
[~SwitchB] interface 10ge 1/0/2
[~SwitchB-10GE1/0/2] shutdown
[*SwitchB-10GE1/0/2] commit
[~SwitchB] quit
# Check the NQA test results.
[~SwitchB] display nqa results test-instance user test
NQA entry(user, test) : testflag is active ,testtype is ICMP 1 . Test 7160 result The test is finished Send operation times: 2 Receive response times: 0 Completion:failed RTD over thresholds number:0 Attempts number:1 Drop operation number:0 Disconnect operation number:0 Operation timeout number:2 System busy operation number:0 Connection fail number:0 Operation sequence errors number:0 RTT Stats errors number:0 Destination ip address:172.16.1.2 Min/Max/Average completion Time: 0/0/0 Sum/Square-Sum completion time: 0/0 Last response packet receiving time: 0000-00-00 00:00:00.0 Lost packet ratio: 100 %
The command output shows "Completion:failed" and "Lost packet ratio: 100 %," indicating that the link is faulty.
# Check the routing table on SwitchB.
[~SwitchB] display ip routing-table
Proto: Protocol Pre: Preference Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route ------------------------------------------------------------------------------ Routing Table : _public_ Destinations : 12 Routes : 12 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 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 172.16.3.0/24 Direct 0 0 D 172.16.3.2 Vlanif30 172.16.3.2/32 Direct 0 0 D 127.0.0.1 Vlanif30 172.16.3.255/32 Direct 0 0 D 127.0.0.1 Vlanif30 172.16.4.0/24 OSPF 10 2 D 172.16.3.1 Vlanif30 172.16.5.0/24 Direct 0 0 D 172.16.5.1 Vlanif50 172.16.5.1/32 Direct 0 0 D 127.0.0.1 Vlanif50 172.16.5.255/32 Direct 0 0 D 127.0.0.1 Vlanif50 172.16.7.0/24 O_ASE 150 20 D 172.16.3.1 Vlanif30 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
The command output shows that the static route has been deleted.
# Check the routing table on SwitchA.
[~SwitchA] display ip routing-table
Proto: Protocol Pre: Preference Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route ------------------------------------------------------------------------------ Routing Table : _public_ Destinations : 11 Routes : 11 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 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 172.16.3.0/24 Direct 0 0 D 172.16.3.1 Vlanif30 172.16.3.1/32 Direct 0 0 D 127.0.0.1 Vlanif30 172.16.3.255/32 Direct 0 0 D 127.0.0.1 Vlanif30 172.16.4.0/24 Direct 0 0 D 172.16.4.1 Vlanif40 172.16.4.1/32 Direct 0 0 D 127.0.0.1 Vlanif40 172.16.4.255/32 Direct 0 0 D 127.0.0.1 Vlanif40 172.16.7.0/24 O_ASE 150 20 D 172.16.4.2 Vlanif40 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
On SwitchB, the NQA test instance is associated with a static route. When NQA detects a link fault, it immediately notifies SwitchB that the static route bound to the link is unreachable. SwitchA cannot learn the route to 172.16.7.0/24 from SwitchB, but it can learn the route to 172.16.7.0/24 from SwitchC. Therefore, you can view that the route to 172.16.7.0/24 has a next hop 172.16.4.2 and cost 20. Service traffic is then switched to the link SwitchC->SwitchD.
Configuration Files
Configuration file of SwitchA
# sysname SwitchA # vlan batch 30 40 # interface Vlanif30 ip address 172.16.3.1 255.255.255.0 # interface Vlanif40 ip address 172.16.4.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 30 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 40 # ospf 1 area 0.0.0.0 network 172.16.3.0 0.0.0.255 network 172.16.4.0 0.0.0.255 # return
Configuration file of SwitchB
# sysname SwitchB # vlan batch 10 30 50 # interface Vlanif10 ip address 172.16.1.1 255.255.255.0 # interface Vlanif30 ip address 172.16.3.2 255.255.255.0 # interface Vlanif50 ip address 172.16.5.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 30 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 10 # interface 10GE1/0/3 port link-type trunk port trunk allow-pass vlan 50 # ospf 1 import-route static cost 10 area 0.0.0.0 network 172.16.3.0 0.0.0.255 # ip route-static 172.16.7.0 255.255.255.0 Vlanif 10 172.16.1.2 track nqa user test # nqa test-instance user test test-type icmp destination-address ipv4 172.16.1.2 interval seconds 5 timeout 4 probe-count 2 frequency 10 start now # return
Configuration file of Switch C
# sysname SwitchC # vlan batch 20 40 60 # interface Vlanif20 ip address 172.16.2.1 255.255.255.0 # interface Vlanif40 ip address 172.16.4.2 255.255.255.0 # interface Vlanif60 ip address 172.16.6.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 20 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 40 # interface 10GE1/0/3 port link-type trunk port trunk allow-pass vlan 60 # ospf 1 import-route static cost 20 area 0.0.0.0 network 172.16.4.0 0.0.0.255 # ip route-static 172.16.7.0 255.255.255.0 Vlanif 60 172.16.6.2 # return