加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

策略路由详解及其常见应用

(2010-06-02 16:27:43)
标签:

it

    

根据网管制定的标准来进行数据包转发的一种机制,策略路由的策略由路由映射图Route Map来定义

Match:

Route Map命令中用来定义匹配的条件,如IP地址,接口,度量值以及数据包长等,匹配语句在路由器的输入端口对数据包进行检测

Set:

Route Map命令中用来定义对符合匹配条件的语句采取的行为,常见行为有

Set ip next hop

    设定数据包下一跳地址

Set interface

  设定数据包出接口

Set ip default next hop

  设定默认下一跳地址,用于当路由表里没有到数据包目的地址路由条目时

Set default interface

  设定默认出接口

Set ip tos

  设定IP数据包的IP Tos

Set ip precedence

  设定IP数据包的优先级

注意:

一个Route Map可以包含多个Route Map陈述,这些语句的执行顺序像ACL一样,从上到下执行;一个Route Map最后默认deny any.

 

分布控制列表

 

http://s5/middle/3fcc38fcg8807e1ca00f4&690



    通过使用分布控制列表控制路由器R1只发送环回接口中第3位为奇数的路由和g0/0接口的路由更新给R2,整个网络运行RIPv2路由协议.

R1(config)#access-list 1 permit 172.16.1.0

R1(config)#access-list 1 permit 1.1.1.0 0.0.254.0

允许第三位为奇数的路由

R1(config)#route rip

R1(config-router)#version 2

    配置RIP版本为2

R1(config-router)#no auto-summary

    关闭auto-summary

R1(config-router)#network 1.0.0.0

R1(config-router)#network 172.16.0.0

R1(config-router)#network 192.168.12.0

R1(config-router)#passive-interface default

默认为被动接口

R1(config-router)#no passive-interface Serial0/0/0

关闭被动接口

R1(config-router)#distribute-list 1 out Serial0/0/0

    出方向配置分布控制列表

R2(config)#router rip

R2(config-router)#version 2

R2(config-router)#no auto-summary

R2(config-router)#network 2.0.0.0

R2(config-router)#network 192.168.12.0

Distribute-list命令可以全局地在一个出或入方向的路由更新中过滤路由,也可以为一个路由进程所涉及的每一个接口的入方向或出方向设置路由过滤.

 

基于IP地址的策略路由

 

http://s9/middle/3fcc38fcg8807dfe4dc88&690



在路由器的R1g0/0接口应用IP策略路由CCNA,使得从主机A来的数据设置下一跳地址为192.168.12.2;从主机B来的数据设置下一跳为192.168.21.2,所有其它的数据包正常转发,整个网络运行EIGRP路由协议.

R1(config)#access-list 1 permit 10.1.1.2

R1(config)#access-list 2 permit 10.1.1.3

R1(config)#route-map CCNA permit 10

R1(config-route-map)#match ip address 1

R1(config-route-map)#set ip next-hop 192.168.12.2

R1(config)#route-map CCNA permit 20

R1(config-route-map)#match ip address 2

R1(config-route-map)#set ip next-hop 192.168.21.2

R1(config)#interface g0/0

R1(config-if)#ip policy route-map CCNA

R1(config)#router eigrp 1

R1(config-router)#no auto-summary

R1(config-router)#network 10.1.1.0 255.255.255.0

R1(config-router)#network 192.168.12.0

R1(config-router)#network 192.168.21.0

 

基于报文大小的策略路由

 

http://s12/bmiddle/5df29937h69caf62c745b&690在路由器R1g0/0接口应用IP策略路由CCNP,使得对大小为64~100字节的数据包设置出接口为s0/0/0;大小为101~1000字节的数据包设置出接口为s0/0/1,所有其它的数据包正常转发,整个网络EIGRP路由协议

R1(config)#route-map CCNP permit 10

  R1(config-route-map)#match length 64 100

R1(config-route-map)#set interface s0/0/0

R1(config)#route-map CCNP permit 20

R1(config-route-map)#match length 101 1000

R1(config-route-map)#set interface s0/0/1

R1(config)#interface g0/0

R1(config-if)#ip policy route-map CCNP

R1(config)#ip local policy route-map CCNP

R1(config)#router eigrp 1

R1(config-router)#no auto-summary

R1(config-router)#network 192.168.12.0

R1(config-router)#network 192.168.21.0

   注意:在接口下应用的策略路由对路由器本地产生的数据包不起作用,如果需要对本地的路由器产生的数据包执行策略路由,要用ip local policy route-map命令配置本地策略

 

基于应用的路由策略

 

http://s9/bmiddle/5df29937h69caf7579938&690在路由器R1g0/0接口应用IP策略路由CCIE,使得对HTTP数据包设置下一跳地址为192.168.12.2,并且设置IP数据包优先级为FLASH,Telnet数据包设置下一跳地址为192.168.21.2,并且设置IP数据包的优先级为critical,所有其它数据包正常转发,整个网络运行EIGRP路由协议

R1(config)#ip access-list extended HTTP

R1(config-ext-nacl)#permit tcp any any eq 80

R1(config)#ip access-list extended TELNET

R1(config-ext-nacl)#permit tcp any any eq 23

R1(config)#route-map CCIE permit 10

R1(config-route-map)#match ip address HTTP

R1(config-route-map)#set ip preccedence flash

R1(config-route-map)#set ip next-hop 192.168.12.2

R1(config)#route-map CCIE permit 20

R1(config-route-map)#match ip address TELNET

R1(config-route-map)#set ip precedence critical

R1(config-route-map)#set ip next-hop 192.168.21.2

R1(config)#interface g0/0

R1(config-if)#ip policy route-map CCIE

R1(config)#ip local policy route-map CCIE

R1(config)#router eigrp 1

R1(config-router)#no auto-summary

R1(config-router)#network 10.1.1.0 255.255.255.0

R1(config-router)#network 192.168.12.0

R1(config-router)#network 192.168.21.0

R2(config)#router eigrp 1

R2(config-router)#network 2.2.2.0 0.0.0.255

R2(config-router)#network 192.168.12.0

R2(config-router)#network 192.168.21.0

R2(config-router)#no auto-summary

R2(config)#ip http server

R2(config)#line vty 0 4

R2(config-line)#no login

R2(config-line)#privilege level 15

 

路由优化命令汇总

Show ip policy

   查看策略路由及作用的接口

Show route-map

  查看定义的所有路由策略及路由策略匹配的情况

Debug ip policy

  动态查看策略路由匹配情况

Passive-interface

  配置被动接口

Distribute-list

  配置分布控制接口

Route-map

  定义路由策略

Match

  定义匹配条件

Set

  定义对符合匹配条件的语句采取的行为

Ip policy route-map

  应用路由策略

Ip local policy route-map

  本地应用路由策略

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有