route-map
(2014-05-13 14:52:40)
标签:
route-map |
分类: IT博客 |
路由映射表(route-map)
①理解route-map
路由映射表是复杂的访问列表,让你能够使用match命令对分组或路由执行某些条件测试。如果条件匹配,则可以采取一些措施来修改分组或路由的属性。这些措施可通过set命令指定。
route-map中的语句相当于访问列表中的各行在路由映射表中视定match条件类似于在访问列表中指定源地址、目标地址和子网掩码。Route-map于access-list最大的区别之一,就是route-map可使用set命令来修改分组或路由。
②应用场景
a)基于策略的路由选择(Policy-Based Routing,PBR):route-map可用于匹配源地址、目标地址、协议类型和最终用户应用程序。当发生匹配时,可使用set命令指定将分组发送到路由器的接口或下一条地址。PBR允许管理员使用所定义的route-map策略进行选路,而不是基于目标地址的IP路由表选路,俗称“策略路由”。我们可以把它看成一种功能比较强大的静态路由。策略路由优先于IP路由表被考虑。
示例:
router(config)#access-list 1 permit 192.168.1.0 0.0.0.255
router(config)#access-list 2 permit 192.168.2.0 0.0.0.255
router(config)#route-map PBR permit 10
router(config-route-map)#match ip address 1
router(config-route-map)#set ip next-hop 1.1.1.2
router(config)#route-map PBR permit 20
router(config-route-map)#match ip address 2
router(config-route-map)#set ip next-hop 2.1.1.2
router(config)#int e0/0
router(config)#ip policy route-map PBR
#表示从该接口进入的IP报文将采用route-map PBR中定义的策略进行转发。
上述配置的涵义:
从e0/0接口收到IP报文时,若源IP地址为192.168.1.0/24范围的,则报文转发至下一跳1.1.1.2
从e0/0接口收到IP报文时,若源IP地址为192.168.2.0/24范围的,则报文转发至下一跳2.1.1.2
从e0/0接口收到IP报文时,若源IP地址不属于上述范围,则报文在策略路由中被拒绝,回到普通的IP路由过程
b)BGP:route-map是实现BGP策略的主要工具。网络管理员将route-map应用于特定BGP会话,以控制允许哪些路由进入或离开BGP进程。route-map还提供完善的操纵BGP路径属性的方法。
c)在路由重发布时,用来控制哪些路由能够重发布(并且控制这些路由的参数)。
示例:
router(config)#ip prefix-list P1 seq 5 permit 0.0.0.0/0 ge 32
router(config)#ip prefix-list P2 seq 5 permit 0.0.0.0/0 ge 26 le 27
router(config)#ip prefix-list P3 seq 5 permit 0.0.0.0/0 ge 24 le 24
router(config)#route-map ALD deny 10
router(config-route-map)#match ip address prefix-list P1
router(config)#route-map ALD permit 20
router(config-route-map)#match ip address prefix-list P2
router(config-route-map)#set metric 2000
router(config-route-map)#set metric-type type-1
router(config)#route-map ALD permit 30
router(config-route-map)#match ip address prefix-list P3
router(config-route-map)#set metric 1000
router(config-route-map)#set metric-type type-2
router(config)#route-map ALD permit 40
router(config-route-map)#set metric 9999
router(config-route-map)#set metric-type type-2
router(config)#router ospf 1
router(config-router)#redistribute static subnets route-map ALD
上述配置的涵义:
a)禁止/32的静态路由重发布到OSPF中;
b)26~27掩码的可以重发布到OSPF中,type为E1、metric为2000;
c)/24掩码的可以重发布到OSPF中,type为E2,metric为1000;
d)其余路由允许重发布,type为E2,metric 9999。
注:①如果数据包没有找到任何匹配,和ACL一样,route map在末尾也有个默认的隐含拒绝所有的操作。如果是在策略路由中匹配失败(拒绝),那么数据包将按正常方式转发;如果是用于路由重分发,并且匹配失败(拒绝),那么路由将不会被重分发;如果route map的陈述中没有match语句,那么默认的操作是匹配所有的数据包和路由。
② 在route-map控制路由重发布时,强烈建议写ACL或IP前缀列表时使用permit,如果希望阻止某条路由重发布可以在route-map语句中deny。
③ 另外需要注意的是route-map是应用在接收接口而不是发送接口。删除某条目时,如不注明语句号,则直接删除整个route-map。
①理解route-map
路由映射表是复杂的访问列表,让你能够使用match命令对分组或路由执行某些条件测试。如果条件匹配,则可以采取一些措施来修改分组或路由的属性。这些措施可通过set命令指定。
route-map中的语句相当于访问列表中的各行在路由映射表中视定match条件类似于在访问列表中指定源地址、目标地址和子网掩码。Route-map于access-list最大的区别之一,就是route-map可使用set命令来修改分组或路由。
②应用场景
a)基于策略的路由选择(Policy-Based Routing,PBR):route-map可用于匹配源地址、目标地址、协议类型和最终用户应用程序。当发生匹配时,可使用set命令指定将分组发送到路由器的接口或下一条地址。PBR允许管理员使用所定义的route-map策略进行选路,而不是基于目标地址的IP路由表选路,俗称“策略路由”。我们可以把它看成一种功能比较强大的静态路由。策略路由优先于IP路由表被考虑。
示例:
router(config)#access-list 1 permit 192.168.1.0 0.0.0.255
router(config)#access-list 2 permit 192.168.2.0 0.0.0.255
router(config)#route-map PBR permit 10
router(config-route-map)#match ip address 1
router(config-route-map)#set ip next-hop 1.1.1.2
router(config)#route-map PBR permit 20
router(config-route-map)#match ip address 2
router(config-route-map)#set ip next-hop 2.1.1.2
router(config)#int e0/0
router(config)#ip policy route-map PBR
#表示从该接口进入的IP报文将采用route-map PBR中定义的策略进行转发。
上述配置的涵义:
从e0/0接口收到IP报文时,若源IP地址为192.168.1.0/24范围的,则报文转发至下一跳1.1.1.2
从e0/0接口收到IP报文时,若源IP地址为192.168.2.0/24范围的,则报文转发至下一跳2.1.1.2
从e0/0接口收到IP报文时,若源IP地址不属于上述范围,则报文在策略路由中被拒绝,回到普通的IP路由过程
b)BGP:route-map是实现BGP策略的主要工具。网络管理员将route-map应用于特定BGP会话,以控制允许哪些路由进入或离开BGP进程。route-map还提供完善的操纵BGP路径属性的方法。
c)在路由重发布时,用来控制哪些路由能够重发布(并且控制这些路由的参数)。
示例:
router(config)#ip prefix-list P1 seq 5 permit 0.0.0.0/0 ge 32
router(config)#ip prefix-list P2 seq 5 permit 0.0.0.0/0 ge 26 le 27
router(config)#ip prefix-list P3 seq 5 permit 0.0.0.0/0 ge 24 le 24
router(config)#route-map ALD deny 10
router(config-route-map)#match ip address prefix-list P1
router(config)#route-map ALD permit 20
router(config-route-map)#match ip address prefix-list P2
router(config-route-map)#set metric 2000
router(config-route-map)#set metric-type type-1
router(config)#route-map ALD permit 30
router(config-route-map)#match ip address prefix-list P3
router(config-route-map)#set metric 1000
router(config-route-map)#set metric-type type-2
router(config)#route-map ALD permit 40
router(config-route-map)#set metric 9999
router(config-route-map)#set metric-type type-2
router(config)#router ospf 1
router(config-router)#redistribute static subnets route-map ALD
上述配置的涵义:
a)禁止/32的静态路由重发布到OSPF中;
b)26~27掩码的可以重发布到OSPF中,type为E1、metric为2000;
c)/24掩码的可以重发布到OSPF中,type为E2,metric为1000;
d)其余路由允许重发布,type为E2,metric 9999。
注:①如果数据包没有找到任何匹配,和ACL一样,route map在末尾也有个默认的隐含拒绝所有的操作。如果是在策略路由中匹配失败(拒绝),那么数据包将按正常方式转发;如果是用于路由重分发,并且匹配失败(拒绝),那么路由将不会被重分发;如果route map的陈述中没有match语句,那么默认的操作是匹配所有的数据包和路由。
前一篇:综合布线材料计算公式