第14章 路由映射

概述

route-map,一个定制路由策略的强大工具。

14.1 路由映射的基本用途

路由映射可用于路由重新分配策略路由
策略路由(policy route)可以基于数据包源地址包头中的其他域向指定的下一跳路由器转发数据包。可链接到扩展IP访问列表,使路由器可以基于协议类型和端口号进行路由选择。
静态路由是基于数据包的目的地址向指定的下一跳路由器转发数据包。

应用场景

场景一

P614 图 14-1

策略路由允许来自AbnerNetde的流量被路由到 ISP1,或者ISP2。
流量的分配可以基于诸如源地址,源/目的地址组合,数据包大小或应用层端口等参数。

场景二

P614 图14-2

策略路由允许来自MONGO系统优先级较高的流量使用FDDI链路,而来自Dilbert系统优先级较低的流量使用56kbit/s链路。

命令格式

路由重新分配的命令

match

表14-1
match interface XX
match ip address 101
match ip next-hop 101
match ip route-source 101
match metric 1000
match route-type internal/external/level-1/level-2
match route-type internal/external type-1/typer-2
match tag 100

set
表14-2
set level level-1/level-2/level-1-2/stub-area/backbone
se metric 100
set metric-type internal/external/type-1/type-2
set next-hop 192.168.1.1
set tag 100

策略路由的命令

match

表14-3
match ip address 102
match length min max

set

表14-4
set default interface e0/0
set interface e0/0
set ip default next-hop 192.168.32.1
set ip next-hop 192.168.21.1
set ip precedene 7
set ip tos type-of-service

14.2 配置路由映射

路由映射必须被调用。 被策略路由命令调用,或者被重新分配命令调用。
策略路由选择将数据包发送到路由映射。
重新分配将路由发送到路由映射。

重新分配案例

  • 例14-1 基本配置。
route-map Hagar permit 10
  match ip address 110
  set metric 100
  • 例14-2 修改操作。
    即使先配置 20,ios仍然按照顺序来摆放。10,15,20
    如果在添加操作中没有指定序列号,那么仅仅会修改语句10.
route-map Hagar 20
match ip address 111
set metric 50  
route-map Hagar 15
  match ip address 112
  set metic 80

*例14-3 删除操作
删除路由映射中的某一个条目。

no route-map Hagar 15

删除整个路由映射,注意喽。

no router-map Hagar
  • 例14-5 顺序执行
    如果路由映射语句中没有match语句,缺省操作是匹配所有数据包和路由。
route-map Sluggo permit 10
match ip route-source 1
set next-hop 192.168.1.1
!
route-map Sluggo permit 20
match ip route-source 2
set next-hop 192.168.1.2
!
route-map Sluggo permit 30
match ip route-source 3
set next-hop 192.168.1.3
!
  • 例14-6 多个匹配和设置语句
    若要执行set语句,每个match语句都必须匹配。
route-map Garfield permit 10
match ip route-source 15
match interface Serial0
set metric-type type-1
set next-hop 10.1.2.3

14.2.1 案例研究:策略路由选择

1, 在接口下配置 ip po0licy route-map 可以定义策略路由。
仅对入站数据包有影响。
2, 全局下配置 ip local policy route-map.
针对路由器自己产生的数据包。

案例一

拓扑

图14-3

配置

  • Linus上的策略路由配置
    仅按照源地址进行策略路由选择,使用标准访问列表
interface Serial0
ip address 172.16.5.1 255.255.255.0
ip policy route-map Sally
!
access-list 1 permit 172.16.6.0 0.0.0.255
access-list 2 permit 172.16.7.0 0.0.0.255
!
route-map Sally permit 10
match ip address 1
set ip next-ho[ 172.16.4.2
!
route-map Sally permit 15
match ip address 2
set ip next-hop 172.16.4.3
!

  • 结果查看
debug ip packet 5  --查看数据包转发
set ip next-hop verify-availability  --强制验证下一跳是否在接口
debug ip policy
debug arp
  • 使用扩展IP访问列表对指定的源目地址进行匹配
interface Serial0
ip address 172.16.5.1 255.255.255.0
ip policy route-map Sally
!
access-list 101 permit ip any host 172.16.1.1
access-list 102 permit ip host 172.16.7.1 host 172.16.1.2
!
route-map Sally permit 10
match ip address 101
set ip next-hop 172.16.4.2
!
route-map Sally permit 15
match ip address 102
set ip next-hop 172.16.4.3
!
  • Schroeder的策略路由用于转发FTP和Telnet的流量
interface Ethernet0
ip address 172.16.1.4 255.255.255.0
ip policy route-map Rerun
!
access-list 105 permit tcp 172.16.1.0 0.0.0.255 eq ftp any
access-list 105 permit tcp 172.16.1.0 0.0.0.255 eq ftp-data any
access-list 105 permit tcp 172.16.1.0 0.0.0.255 eq telnet any
!
route-map Rerun permit 10
match ip address 105
set ip next-hop 172.16.2.1
!
route-map Rerun permit 20
match ip address 106
set ip next-hop 172.16.3.1
!
  • Schroeder的策略路由配置基于数据包长度转发流量
interface Ethernet0
ip address 172.16.1.4 255.255.255.0 
ip policy route-map Woodstock
!
route-map Woodstock permit 20
match length 1000 1600
set ip next-hop 172.16.2.1
!
route-map Woodstock permit 30
match length 0 400
set ip next-hop 172.16.3.1
!
  • 针对Schroeder产生数据包的策略路由配置
interface Ethernet0
ip address 172.16.1.4 255.255.255.0
ip policy route-map Woodstock
!
ip local policy route-map Woodstock
!
access-list 120 permit ip any 172.16.1.0 0.0.0.255
access-list 120 permit ospf any any
!
route-map Woodstock permit 10  //注意这个条目下是没有动作的
match ip address 120 
!
route-map Woodstock permit 20
match length 1000 1600
set ip next-hop 172.16.2.1
!
route-map Woodstock permit 30
match length 0 400
set ip next-hop 172.16.3.1
!

14.2.2 案例研究:策略路由选择和服务质量路由选择

优先级

Tos

在Pogo设置优先级和Tos位

interface Serial0
ip address 10.1.18.67 255.255.255.252
ip policy route-map Albert
!
interface Serial1
ip address 10.34.16.83 255.255.255.252
ip policy route-map Albert
!
access-list 1 permit 172.16.0.0 0.0.255.255
access-list 110 permit tcp any eq www any
!
route-map Albert permit 10
match ip address 1 110
set ip precedence critical
!
route-map Albert permit 20  //匹配所有10不匹配的数据包
set ip tos 10
set ip precedenc priority
!

14.2.3 案例研究:路由映射和重新分配

在IPv4和IPv6协议下,通过redistribute命令中添加路由映射的调用就可以使用路由映射和重新分配一起使用。
图14-8

router ospf 1
redistribute isis level-a metric 20 subnets route-map Griffy
network 172.16.10.2 0.0.0.0 area 5
!
router isis
redistribute ospf 1 metric 25 route-map Toad metric-type internal levevl-2
net 47.0001.1234.5678.9056.00
!
access-list 1 permit 192.168.1.0
access-list 2 permit 172.16.1.0
!
//否定逻辑,标识那些不被重新分配的路由
route-map Griffy deny 10
match ip address 1
!
route-map Griffy permit 20
!
// 使用肯定逻辑,标识将要被重新分配的路由
route-map Toad permit 10
match ip address 2
!

14.2.4 案例研究:路由标记

14.2.5 案例研究:从OSPF路由表中滤掉被标记的路由

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值