策略路由实验
实验需求:
市场部使用R1-R2-R4访问总部
财务部使用R1-R3-R4访问总部
策略路由基于数据层面进行控制,并且策略路由优于路由表进行转发,不需要看路由表,对路由表无影响,而路由策略是基于控制层面,会影响路由表的发布和转发。
策略路由:数据流量(数据层面)
路由策略 : 路由发布(控制层面)
路由策略和策略路由
路由策略是根据一些规则,使用某种策略改变规则中/影响路由发布、接收或路由选择/的参数而改变路由发现的结果,最终改变的是路由表的内容。是在路由发现的时候产生作用。
策略路由是尽管存在当前最优的路由,但是针对某些特别的主机(或应用、协议)不使用当前路由表中的转发路径而单独使用别的转发路径。在数据包转发的时候发生作用、不改变路由表中任何内容。
策略路由的优先级比路由策略高,当路由器接收到数据包,并进行转发的时候,会优先根据策略路由的规则进行匹配,如果能匹配上,则根据策略路由来转发,否则按照路由表中转发路径来进行转发。
,路由策略是路由发现规则,策略路由是数据包转发规则。其实将“策略路由”理解为“转发策略”,这样更容易理解与区分。由于转发在底层,路由在高层,所以转发的优先级比路由的优先级高,这点也能理解的通。
其实路由器中存在两种类型和层次的表,一个是路由表(routing-table),另一个是转发表(forwording-table)。转发表是由路由表映射过来的,策略路由直接作用于转发表,路由策略直接作用于路由表。
配置脚本:
sys
sys AR1
int g0/0/1
ip add 10.1.1.254 24
int g0/0/2
ip add 10.1.2.254 24
int g4/0/0
ip add 12.1.1.1 24
int g3/0/0
ip add 13.1.1.1 24ospf 1 rout 1.1.1.1
area 0
net 10.1.1.254 0.0.0.0
net 10.1.2.254 0.0.0.0
net 12.1.1.1 0.0.0.0
net 13.1.1.1 0.0.0.0sys
sys AR2
int g0/0/2
ip add 12.1.1.2 24
int g0/0/0
ip add 24.1.1.2 24ospf 1 rout 2.2.2.2
area 0
net 12.1.1.2 0.0.0.0
net 24.1.1.2 0.0.0.0sys
sys AR3
int g0/0/2
ip add 13.1.1.3 24
int g0/0/0
ip add 34.1.1.3 24ospf 1 rout 3.3.3.3
area 0
net 13.1.1.3 0.0.0.0
net 34.1.1.3 0.0.0.0sys
sys AR4
int g0/0/1
ip add 34.1.1.4 24
int g0/0/0
ip add 24.1.1.4 24
int g0/0/2
ip add 10.1.3.254 24ospf 1 rout 4.4.4.4
area 0
net 10.1.3.254 0.0.0.0
net 24.1.1.4 0.0.0.0
net 34.1.1.4 0.0.0.0
策略路由配置思路
AR1策略路由
acl 3000
流分类
流行为
流策略
接口调用
0.acl匹配感兴趣流量
acl number 3000
rule 5 permit ip source 10.1.1.0 0.0.0.255 destination 10.1.3.0 0.0.0.255
1.流分类
traffic classifier 1-4 operator or
if-match acl 3000
2.流行为
traffic behavior R2
redirect ip-nexthop 12.1.1.2
statistic enable
3.流策略
traffic policy shichang
classifier 1-4 behavior R2
4.接口下调用策略
interface GigabitEthernet0/0/1
ip address 10.1.1.254 255.255.255.0
traffic-policy shichang inbound
AR1配置如下:
<AR1>dis cu
[V200R003C00]
#
sysname AR1
#
board add 0/3 1GEC
board add 0/4 1GEC
#
acl number 3000
rule 10 permit ip source 10.1.1.0 0.0.0.255 destination 10.1.3.0 0.0.0.255
acl number 3001
rule 5 permit ip source 10.1.2.0 0.0.0.255 destination 10.1.3.0 0.0.0.255
#
traffic classifier caiwu operator or
if-match acl 3001
traffic classifier 1-4 operator or
if-match acl 3000
#
traffic behavior R3
redirect ip-nexthop 13.1.1.3
statistic enable
traffic behavior R2
redirect ip-nexthop 12.1.1.2
statistic enable
#
traffic policy caiwu
classifier caiwu behavior R3
traffic policy shichang
classifier 1-4 behavior R2
#
interface GigabitEthernet0/0/1
ip address 10.1.1.254 255.255.255.0
traffic-policy shichang inbound
#
interface GigabitEthernet0/0/2
ip address 10.1.2.254 255.255.255.0
traffic-policy caiwu inbound
#
interface GigabitEthernet3/0/0
ip address 13.1.1.1 255.255.255.0
#
interface GigabitEthernet4/0/0
ip address 12.1.1.1 255.255.255.0
#
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 10.1.1.254 0.0.0.0
network 10.1.2.254 0.0.0.0
network 12.1.1.1 0.0.0.0
network 13.1.1.1 0.0.0.0
AR2配置如下:
<AR2>dis cu
[V200R003C00]
#
sysname AR2
#
interface GigabitEthernet0/0/0
ip address 24.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 12.1.1.2 255.255.255.0
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 12.1.1.2 0.0.0.0
network 24.1.1.2 0.0.0.0
AR3配置如下:
<AR3>dis cu
[V200R003C00]
#
sysname AR3
#
interface GigabitEthernet0/0/0
ip address 34.1.1.3 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 13.1.1.3 255.255.255.0
#
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 13.1.1.3 0.0.0.0
network 34.1.1.3 0.0.0.0
AR4配置如下:
<AR4>dis cu
[V200R003C00]
#
sysname AR4
#
interface GigabitEthernet0/0/0
ip address 24.1.1.4 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 34.1.1.4 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 10.1.3.254 255.255.255.0
#
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 10.1.3.254 0.0.0.0
network 24.1.1.4 0.0.0.0
network 34.1.1.4 0.0.0.0
验证如下: