陈银山 发表于 2018-7-19 10:53:41

Cisco基于策略路由的配置实例

问题描述  您可以定义自己的规则来进行数据包的路由而不仅仅由目的地地址所决定。在这里
  您可以学到怎么使用基于策略路由的办法来解决这一问题。
  在具体的应用中,基于策略的路由有:
  ☆ 基于源IP地址的策略路由
  ☆ 基于数据包大小的策略路由
  ☆ 基于应用的策略路由
  ☆ 通过缺省路由平衡负载
  这里,讲述了第一种情况的路由策略。
  举例
  在这个例子中,防火墙的作用是:把10.0.0.0/8内部网地址翻译成可路由的172.16
  .255.0/24子网地址。
  下面的防火墙配置是为了完整性而加进去的,它不是策略路由配置所必需的。在这
  里的防火墙可以被其它类似的产品代替,如PIX或其它类似防火墙设备。这里的防火墙的
  配置如下:
  !
  ip nat pool net-10 172.16.255.1 172.16.255.254 prefix-length 24
  ip nat inside source list 1 pool net-10
  !
  interface Ethernet0
  ip address 172.16.20.2 255.255.255.0
  ip nat outside
  !
  interface Ethernet1
  ip address 172.16.39.2 255.255.255.0
  ip nat inside
  !
  router eigrp 1
  redistribute static
  network 172.16.0.0
  default-metric 10000 100 255 1 1500
  !
  ip route 172.16.255.0 255.255.255.0 Null0
  access-list 1 permit 10.0.0.0 0.255.255.255
  !
  end
  在我们的例子中,Cisco WAN路由器上运行策略路由来保证从10.0.0.0/8网络来的I
  P数据包被发送到防火墙去。配置中定义了两条net-10策略规则。第一条策略就定义了从
  10.0.0.0/8网络来的IP数据包被发送到防火墙去(我们很快会看到这里的配置有问题)
  。而第二条规则允许所有的其它数据包能按正常路由。这里的Cisco WAN路由器的配置如
  下:
  !
  interface Ethernet0/0
  ip address 172.16.187.3 255.255.255.0
  no ip directed-broadcast
  !
  interface Ethernet0/1
  ip address 172.16.39.3 255.255.255.0
  no ip directed-broadcast
  !
  interface Ethernet3/0
  ip address 172.16.79.3 255.255.255.0
  no ip directed-broadcast
  ip policy route-map net-10
  !
  router eigrp 1
  network 172.16.0.0
  !
  access-list 110 permit ip 10.0.0.0 0.255.255.255 172.16.36.0 0.0.0.255
  access-list 111 permit ip 10.0.0.0 0.255.255.255 any
  !
  route-map net-10 permit 10
  match ip address 111
  set interface Ethernet0/1
  !
  route-map net-10 permit 20
  !
  end
  我们可以这样测试我们所做的配置。在名为Cisco-1的路由器10.1.1.1上发送ping命
  令到Internet上的一个主机(这里就是192.1.1.1主机)。要查看名为Internet Router
  的路由器上的情况,我们在特权命令模式下执行debug ip packet 101 detail命令。(
  其中,在此路由器上有access-list 101 permit icmp any any配置命令)。下面是输出
  结果:
  Results of ping from Cisco-1 to 192.1.1.1/internet taken from Internet_R
  outer:
  Pakcet never makes it to Internet_Router
  正如您所看到的:数据包没有到达Internet_Router路由器。下面的在Cisco WAN路
  由器上的debug命令给出了原因:
  Debug commands run from Cisco_WAN_Router:
  "debug ip policy"
  2d15h: IP: s=10.1.1.1 (Ethernet3/0), d=192.1.1.1, len 100, policy match
  2d15h: IP: route map net-10, item 10, permit
  2d15h: IP: s=10.1.1.1 (Ethernet3/0), d=192.1.1.1 (Ethernet0/1), len 100,
  policy routed
  2d15h: IP: Ethernet3/0 to Ethernet0/1 192.1.1.1
  这里,数据包确实匹配了net-10策略图中的第一条规则。但为什么还是没有达到预
  期的目的呢?用"debug arp"来看一下。
  "debug arp"
  2d15h: IP ARP: sent req src 172.16.39.3 0010.7bcf.5b02,
  dst 192.1.1.1 0000.0000.0000 Ethernet0/1
  2d15h: IP ARP rep filtered src 192.1.1.1 00e0.b064.243d,
页: [1]
查看完整版本: Cisco基于策略路由的配置实例