1.实验拓扑
2.实验配置
<SW1>dis cu
#
sysname SW1
#
vlan batch 2 10 30
#
dhcp enable
#
interface Vlanif2
ip address 10.1.1.2 255.255.255.0
#
interface Vlanif10
ip address 192.168.10.253 255.255.255.0
dhcp select interface
dhcp server excluded-ip-address 192.168.10.254
#
interface Vlanif30
ip address 192.168.30.254 255.255.255.0
dhcp select interface
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 2
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 10
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 30
#
ospf 1
area 0.0.0.0
network 192.168.10.0 0.0.0.255
network 192.168.30.0 0.0.0.255
network 10.1.1.0 0.0.0.255
#
<SW2>dis cu
#
sysname SW2
#
vlan batch 20
#
dhcp enable
#
interface Vlanif20
ip address 192.168.20.253 255.255.255.0
dhcp select interface
dhcp server excluded-ip-address 192.168.20.254
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 20
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 20
#
ospf 1
area 0.0.0.0
network 192.168.20.0 0.0.0.255
#
<R1>dis cu
[V200R003C00]
#
sysname R1
#
acl number 3000
rule 5 permit ip source 192.168.10.0 0.0.0.255 destination 192.168.20.0 0.0.0.2
55
acl number 3010
rule 5 permit ip source 192.168.30.0 0.0.0.255 destination 192.168.20.0 0.0.0.2
55
#
traffic classifier yidong operator or
if-match acl 3010
traffic classifier dianxin operator or
if-match acl 3000
#
traffic behavior yidong
redirect ip-nexthop 13.1.1.3 track nqa 13 34
traffic behavior dianxin
redirect ip-nexthop 12.1.1.2 track nqa 12 24
#
traffic policy chukou
classifier dianxin behavior dianxin
classifier yidong behavior yidong
#
interface GigabitEthernet0/0/0
ip address 12.1.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 13.1.1.1 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 10.1.1.1 255.255.255.0
traffic-policy chukou inbound
#
ospf 1
default-route-advertise
area 0.0.0.0
network 10.1.1.0 0.0.0.255
#
ip route-static 0.0.0.0 0.0.0.0 12.1.1.2
ip route-static 0.0.0.0 0.0.0.0 13.1.1.3
#
nqa test-instance 12 24
test-type icmp
destination-address ipv4 24.1.1.4
frequency 5
probe-count 1
start now
nqa test-instance 13 34
test-type icmp
destination-address ipv4 34.1.1.4
frequency 5
probe-count 1
start now
#
<R4>dis cu
[V200R003C00]
#
sysname R4
#
acl number 3000
rule 5 permit ip source 192.168.20.0 0.0.0.255 destination 192.168.10.0 0.0.0.2
55
acl number 3010
rule 5 permit ip source 192.168.20.0 0.0.0.255 destination 192.168.30.0 0.0.0.2
55
#
traffic classifier yidong operator or
if-match acl 3010
traffic classifier dianxin operator or
if-match acl 3000
#
traffic behavior yidong
redirect ip-nexthop 34.1.1.3 track nqa 34 13
traffic behavior dianxin
redirect ip-nexthop 24.1.1.2 track nqa 24 12
#
traffic policy chukou
classifier dianxin behavior dianxin
classifier yidong behavior yidong
#
interface GigabitEthernet0/0/0
ip address 34.1.1.4 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 24.1.1.4 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 192.168.20.254 255.255.255.0
traffic-policy chukou inbound
#
ospf 1
default-route-advertise
area 0.0.0.0
network 192.168.20.0 0.0.0.255
#
ip route-static 0.0.0.0 0.0.0.0 24.1.1.2
ip route-static 0.0.0.0 0.0.0.0 34.1.1.3
#
nqa test-instance 24 12
test-type icmp
destination-address ipv4 12.1.1.1
frequency 5
probe-count 1
start now
nqa test-instance 34 13
test-type icmp
destination-address ipv4 13.1.1.1
frequency 5
probe-count 1
start now
#
<R2>dis cu
[V200R003C00]
#
sysname R2
#
interface GigabitEthernet0/0/0
ip address 24.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 12.1.1.2 255.255.255.0
#
ip route-static 192.168.10.0 255.255.255.0 12.1.1.1
ip route-static 192.168.20.0 255.255.255.0 24.1.1.4
ip route-static 192.168.30.0 255.255.255.0 12.1.1.1
#
<R3>dis cu
[V200R003C00]
#
sysname R3
#
interface GigabitEthernet0/0/0
ip address 13.1.1.3 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 34.1.1.3 255.255.255.0
#
ip route-static 192.168.10.0 255.255.255.0 13.1.1.1
ip route-static 192.168.20.0 255.255.255.0 34.1.1.4
ip route-static 192.168.30.0 255.255.255.0 13.1.1.1
#
3.实验现象
正常情况下,PC3流量走yidong,PC1流量走dianxin。
此时将R1的GE0/0/1口断开
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]shutdown
在路由可达的情况下,配置NQA可以避免在接口出现问题的情况下出现流量来回路径不一致导致丢包。
接口恢复后