欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

思科路由过滤命令详细解说

程序员文章站 2022-05-02 16:01:44
思科路由过滤命令详细解说...

  (一) route maps

  特性:

  route maps类似于access lists,不同之处在于route maps可以改变packets/routes的部分属性。

  用途:

  route maps主要用于redistribution和policy routing及bgp的实现。

  实现:

  policy routing发送packets到route maps实现策略路由转发。

  redistribution发送routes到route maps实现路由条目的过滤。

  配置说明:

  route maps如果没有指定action及sequence number属性,默认:

  action:   permit

  sequence number:   10

  且sequence number不会自动增加。

  即如果在使用route maps语句时不指定sequence number,则覆盖sequence number为10的默认条目。

  route maps deny action:

  redistribution: 特定路由条目不会被重分布。

  policy routing: 特定的packets不会按策略路由转发,但会梗概正常的路由表条目转发。

  case study:policy routing

  注:(1)policy routing只影响入流量。

  (2)可以使用standard及extended acl.

  (3)全局配置ip local policy route-map sense可将策略路由应用于router本身发送的packets.

  <1> standard acl

interface serial 0
   ip address 172.16.5.1 255.255.255.0
   ip policy route-map sense
!
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 sense permit 10
   match ip address 1
   set ip next-hop 172.16.4.2
!
route-map sense permit 20
   match ip address 2
   set ip next-hop 172.16.4.3

  <2> extended acl

interface ethernet 0
   ip address 172.16.1.4 255.255.255.0
   ip policy route-map sense
!
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 106 permit tcp 172.16.1.0 0.0.0.255 eq telnet any
!
route-map sense permit 10
   match ip address 105
   set ip next-hop 172.16.2.1
!
route-map sense permit 20
   match ip address 106
   set ip next-hop 172.16.3.1

  <3> length of the packets

interface ethernet0
   ip address 172.16.1.4 255.255.255.0
   ip policy route-map sense
!
route-map sense permit 10
   match length 1000 1600
   set ip next-hop 172.16.2.1
!
route-map sense permit 20
   match length 0 400
   set ip next-hop 172.16.3.1

  <4> router's packets

interface ethernet0
   ip address 172.16.1.4 255.255.255.0
   ip policy route-map sense
!
ip local policy route-map sense
!
access-list 120 permit ip any 172.16.1.0 0.0.0.255
access-list 120 permit ospf any any
!
route-map sense permit 10
   match ip address 120
!
route-map sense permit 20
   match length 1000 1600
   set ip next-hop 172.16.2.1
!
route-map sense permit 30
   match length 0 400
   set ip next-hop 172.16.3.1

  注:如果没有第一个route-map条目,router本身的packets及ospf的packets都会由于后两个route-map语句被转发到错误的地址。

  case study: policy routing and quality of service routing

  policy routing结合ip包头的precedence和type of service(tos)可以实现基于qos的策略路由。

  注:precedence和tos的配置既可使用number字段,也可以使用keyword.

set ip precedence
-------------------------------------
bits     number     keyword
000        0        routine
001        1        priority
010        2        immediate
011        3        flash
100        4        flash-override
101        5        critical
110        6        internet
111        7        network
-------------------------------------
set ip tos
-------------------------------------
bits     number     keyword
0000       0        normal
0001       1        min-monetary-cost
0010       2        max-reliability
0100       4        max-throughput
1000       8        min-delay
-------------------------------------
interface serial0
   ip address 10.1.18.67 255.255.255.252
   ip policy route-map sense
!
interface serial1
   ip address 10.34.16.83.255.255.255.252
   ip policy route-map sense
!
access-list 1 permit 172.16.0.0 0.0.255.255
access-list 110 permit tcp any eq www any
!
route-map sense permit 10
   match ip address 1 110
   set ip precedence critical
!
route-map sense permit 20
   set ip tos 10
   set ip precedence priority

  case study: route tagging

  用途:

  用于双向重分布时标识特定domain的路由,以防路由被重分布回起源domain.

  使用方案:

  通告路由条目的边缘router在重分布时给路由条目加上tag标识,做为transit network的domain,不需要使用和识别tag,仅仅需要将它传递到它的外部网络即可。

  路由协议相关:

  support: ripv2,eigrp,is-is,ospf,bgp

  not support: ripv1,igrp

  packets format:

  ripv2: 支持16-bit tags    表示为十进制:0 ~ 65535

  eigrp external route tlvs: 支持32-bit tags    表示为十进制:0 ~ 4294967295

  ospf type 5 lsas: 支持32-bit tags    表示为十进制:0 ~ 4294967295

  配置实例:

router ospf 1
   redistribute igrp 1 metric 10 subnets tag 1
   redistribute rip metric 10 subnets route-map sense
   network 10.100.200.1 0.0.0.0 area 0
!
router rip
   network 10.0.0.0
!
router igrp 1
   network 10.0.0.0
!
access-list 1 permit 10.1.2.3
access-list 2 permit 10.1.2.4
!
route-map sense permit 10
   match ip route-source 1
   set tag 2
!
route-map sense permit 20
   match ip route-source 2
   set tag 3