如图所示:以3ping 1 和3 ping 2分别走不同的路径
则目的不同源相同,则匹配目的

sw-1:
sysname sw-1
#
vlan batch 12 to 13 24 34
#
stp disable
#
interface Vlanif12
ip address 12.1.1.1 255.255.255.0
#
interface Vlanif13
ip address 13.1.1.1 255.255.255.0
#
interface GigabitEthernet0/0/47
port link-type access
port default vlan 13
#
interface GigabitEthernet0/0/48
port link-type access
port default vlan 12
#
interface LoopBack0
ip address 192.168.1.1 255.255.255.0
#
interface LoopBack1
ip address 192.168.2.1 255.255.255.0
#
interface LoopBack2
ip address 192.168.3.1 255.255.255.0
#
ospf 1
area 0.0.0.0
network 0.0.0.0 255.255.255.255
sw-2
sysname sw-2
#
vlan batch 12 to 13 24 34
#
interface Vlanif12
ip address 12.1.1.2 255.255.255.0
#
interface Vlanif24
ip address 24.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/47
port link-type access
port default vlan 12
#
interface GigabitEthernet0/0/48
port link-type access
port default vlan 24
#
ospf 1
area 0.0.0.0
network 0.0.0.0 255.255.255.255
return
sw-3
sysname sw-3
#
vlan batch 12 to 13 24 34 666
#
interface Vlanif13
ip address 13.1.1.3 255.255.255.0
#
interface Vlanif34
ip address 34.1.1.3 255.255.255.0
#
interface GigabitEthernet1/0/47
port link-type access
port default vlan 13
#
interface GigabitEthernet1/0/48
port link-type access
port default vlan 34
#
ospf 1
area 0.0.0.0
network 0.0.0.0 255.255.255.255
sw-4
sysname sw-4
#
vlan batch 12 to 13 24 34
#
acl number 3011
rule 5 permit ip destination 192.168.1.1 0
acl number 3021
rule 5 permit ip destination 192.168.2.1 0
#
traffic classifier 11 operator and
if-match acl 3011
traffic classifier 21 operator and
if-match acl 3021
#
traffic behavior b11
redirect ip-nexthop 24.1.1.2
traffic behavior b21
redirect ip-nexthop 34.1.1.3 //重定向,只在接口的入方向,也就是接口的in方向
#
traffic policy Policy match-order config
classifier 11 behavior b11
classifier 21 behavior b21
#
interface Vlanif1
ip address 10.1.1.254 255.255.255.0
#
interface Vlanif24
ip address 24.1.1.4 255.255.255.0
#
interface Vlanif34
ip address 34.1.1.4 255.255.255.0
#
interface GigabitEthernet2/0/34
port link-type access
traffic-policy Policy inbound
#
interface GigabitEthernet2/0/47
port link-type access
port default vlan 34
#
interface GigabitEthernet2/0/48
port link-type access
port default vlan 24
#
ospf 1
area 0.0.0.0
network 0.0.0.0 255.255.255.255
实例分析:
由pc-1 ping pc-2和pc-6分别走不通的链路,一个走左边一个走右边:
因为这个是同一个源访问不同的目的,因此匹配目的;
且在接口调用时注意:在sw-4的g0/0/3口,因为在这里流量分流了。
因此记住:里调用接口最近的接口调用。
切记目的地址匹配时,目的地址必须的精确地址不能是网段,不然不会走策略路由




