在实际网络应用中,策略路由也是一种重要的技术手段。尽管在考试并不注重策略路由,但是实际上应用较多建议考生除了掌握基本的静态路由协议IP route-static,动态路由协议RIP、还要掌握如何配置策略路由。策略路由的基本原理:根据ACL定义的不同数OSPF的基础配置外,据流经过路由器时,使用基于原地址或者基于目标地址策略转发数据到下一个接口,案例如下图所示:
一、案例说明
RouterA、RouterB和RouterC使用OSPF保证全网路由可达,并且在RouterA上查看路由表可以发现10.0.0.0的下一跳为Routerc的GE1/0/0接口地址。
在RouterA上应用策略路由,使10.0.2.0/24到10.0.0.0/24的流量重定向到RouterB上。
二、RouterA配置文件:
[RouterA] acl number 3001
//定义ACL匹配目的源地址是10.0.2.0/24,目的地址是10.0.0.0/24
[RouterA-acl-adv-3001] rule 5 permit ip source 10.0.2.0 0.0.0.255 destination 10.0.0.0 0.0.0.255
[RouterA-acl-adv-3001] quit
[RouterA] traffic classifier credirect operatoror //定义需要重定向的数据流分类
[RouterA-classifier-credirect]if-match acl 3001
[RouterA-classifier-credirect]quit
[RouterA]traffic behavior bredirect //定义流行为重定向到RouterB的GE1/0/0的接口地址
[RouterA-behavior-bredirect]redirect ip-nexthop 10.181.10.2
[RouterA-behavior-bredirectlquit
[RouterA]traffic policy predirect //绑定流策略
[RouterA- policy-predirect]classifier credirect behavior bredirect
[RouterA- policy-predirect] quit
[RouterA]interface GigabitEthernet 1/0/0
[RouterA- GigabitEthernet 1/0/0]ip address 10.181.20.1 255.255.255.0
[RouterA- GigabitEthernet 1/0/0]quit[RouterA]interface GigabitEthernet 2/0/0
[RouterA- GigabitEthernet 2/0/0]ip address 10.181.10.1 255.255.255.0
[RouterA- GigabitEthernet 2/0/0]quit
[RouterA]interface GigabitEthernet 3/0/0
[RouterA- GigabitEthernet3/0/0]ip address 10.0.2.1 255.255.255.0
[RouterA- GigabitEthernet3/0/0]traffic-policy pbredirect inbound //从10.0.2.0/24到10.0.0.0/24的流量重定向到RouterB上
[RouterA- GigabitEthernet3/0/0]quit
[RouterA]ospf1 //配置OSPF路由协议
[RouterA-ospf-1] area 0.0.0.0
[RouterA-ospf-1-area-0.0.0.0]network 10.0.2.0 0.0.0.255
[RouterA-ospf-1-area-0.0.0.0]network 10.181.20.0 0.0.0.255
[RouterA-ospf-1-area-0.0.0.0]network 10.181.10.0 0.0.0.255
[RouterA-ospf1]quit
三、RouterB配置文件:
[RouterB]interface GigabitEthernet 1/0/0
[RouterB- GigabitEthernet 1/0/0]ip address 10.181.10.2 255.255.255.0
[RouterB- GigabitEthernet 1/0/0]quit
[RouterB]interface GigabitEthernet 2/0/0
[RouterB- GigabitEthernet 2/0/0]ip address 10.184.10.1 255.255.255.0
[RouterB- GigabitEthernet 2/0/0]quit
[RouterB]ospf1 //配置OSPF路由协议
[RouterB-ospf-1]area 0.0.0.0
[RouterB-ospf-1-area-0.0.0.0]network 10.181.10.0 0.0.0.255
[RouterB-ospf-1-area-0.0.0.0]network 10.184.10.0 0.0.0.255
[RouterB-ospf-1-area-0.0.0.0]quit
四、RouterC配置文件:
[RouterC]interface GigabitEthernet 1/0/0
[RouterC-GigabitEthernet 1/0/0]ip address 10.181.20.2 255.255.255.0
[RouterC- GigabitEthernet 1/0/0]quit
[RouterC]interface GigabitEthernet 2/0/0
[RouterC-GigabitEthernet 2/0/0]ip address 10.184.10.2 255.255.255.0
[RouterC- GigabitEthernet 2/0/0]quit
[Routerc]ospf1 //配置OSPF路由协议
[RouterC-ospf-1]area 0.0.0.0
[Routerc-ospf-1-area-0.0.0.0]network 10,184.10.0 0.0.0.255
[Routerc-ospf-1-area-0.0.0.0]network 10.181.20.0 0.0.0.255
[Routerc-ospf-1-area-0.0.0.0]network 10.0.0.0 0.0.0.255
标签:10.0,0.0,模型,GigabitEthernet,网络,RouterB,RouterA,ospf,路由 From: https://blog.csdn.net/limengshi138392/article/details/139205153