高级会员
 精华: 1
 积分: 512
 帖子: 63  威望: 179 点 金钱: 117 币 贡献: 80 点 经验: 02级
 阅读权限: 50
 注册: 2007-8-17
 状态:
|
1#
大 中
小 发表于 2007-11-14 09:25 只看该作者
策略路由!!!!!!
本实验参考实验手册二(上),8-4 通过缺省路由负载均衡 :
拓扑如下:
------------------------------------------------------------ --------------
------------------------------------------------------------ ---------------
实验目的:
< 1 > 利用缺省和策略路由, 在R2没有3.3.3.0/24 的路由情况下:
使R1的1.1.X.0/24 (X=0, 1,2,3) 网络通过 R2的S1/0 访问R3的3.3.3.3
而R1的1.1.4.0/24 网络通过R2的E0/0 接口访问R3的3.3.3.3 网络,
实现负载均衡!
< 2 > 实验目的 1 ,策略是可以实现的 , 但会发现 R1访问3.3.3.0/24网络 ,通过R2的E0/0接口的不通的, 原因何在? 在R2上改策略,使之正常通讯 !
< 3 > 实验涉及到策略命令:
Set default interface
Set interface
Set ip next-hop
三条命令的作用 及其区别 ,给予证实 !
目的< 1 >实验配置:
R1和R2 之间通过OSPF 互通:
R1 : router ospf 1
router-id 1.1.1.1
network 0.0.0.0 255.255.255.255 area 0
$ 使R1所有接口启用OSPF
R2 : router ospf 10
router-id 2.2.2.2
network 0.0.0.0 255.255.255.255 area 0
default-information originate always
$ 通告一条默认路由给R1
( 注意: always参数,其作用是:不需要R2本身有静态默认路由存在! 如果没有这个参数,则必须要有静态默认路由存在,哪怕是空路由 )
R1 路由表里将学习到R2通告的OSPF 默认路由:
O*E2 0.0.0.0/0 [110/1] via 12.1.1.2, 00:32:24, Serial1/0
目的就是为了让R1 成功的发出关于3.3.3.0/24 这个网络的数据包,不会不可路由!
R3 则只需要一条静态缺省即可 : ip route 0.0.0.0 0.0.0.0 23.1.1.2
下面在R2 上做策略 :
( 1 ) 定义来自R1源IP地址范围 :
R2(config)#access-list 10 permit 1.1.0.0 0.0.3.255
R2(config)#access-list 20 permit 1.1.4.0 0.0.0.255
( 2 ) Route-map 引用访问列表,配置默认出口 :
R2(config-route-map)#route-map to-R3 permit 10
$ 默认序号为 10
R2(config-route-map)#match ip address 10
R2(config-route-map)#set default interface s1/0
R2(config-route-map)#route-map to-R3 permit 20
R2(config-route-map)#match ip address 20
R2(config-route-map)#set default interface e0/0
( 3 ) 在接口上应用策略 : ( 实验手册没印上,在此补充 )
R2(config)#interface s2/0
R2(config-if)#ip policy route-map to-R3
注意 : 策略路由要设置在接收报文的接口 !
OK , 配置完成 ,我们测试以下, 在R2上用debug ip policy 命令, R1扩展Ping 3.3.3.3
网络源接口为1.1.1.1 查看debug 信息 :
R2#debug ip policy
Policy routing debugging is on
R2#
*Sep 15 08:50:26.947: IP: s=1.1.1.1 (Serial2/0), d=3.3.3.3, len 100, policy match
*Sep 15 08:50:26.947: IP: route map to-R3, item 10, permit
*Sep 15 08:50:26.947: IP: s=1.1.1.1 (Serial2/0), d=3.3.3.3 (Serial1/0), len 100, policy routed
*Sep 15 08:50:26.947: IP: Serial2/0 to Serial1/0 3.3.3.3
当R1的的发包接口改为 1.1.4.1 时, 查看 R2 debug 信息 :
*Sep 15 11:34:37.819: IP: s=1.1.4.1 (Serial2/0), d=3.3.3.3, len 100, policy match
*Sep 15 11:34:37.819: IP: route map to-R3, item 20, permit
*Sep 15 11:34:37.819: IP: s=1.1.4.1 (Serial2/0), d=3.3.3.3 (Ethernet0/0), len 100, policy routed
*Sep 15 11:34:37.819: IP: Serial2/0 to Ethernet0/0 3.3.3.3
OK ! 策略实现 !
但问题出现了, 刚才用R1的1.1.4.1 Ping R3的3.3.3.3时,虽说策略实现, 但不通!!!
目的< 2 > 分析 :
在Ethernet链路上, 必须获得下 1 跳的MAC地址, 若已知目的 IP 地址可以通过ARP解析出对应的MAC地址 ,完成封装及互连.
但我们在R2上配置策略时 : default interface E0/0 .我们之规定了一个接口, 并不是下一跳的具体地址 ! 我们来测试一下:
R1 : R1#debug ip packet
IP packet debugging is on
*Sep 15 11:53:45.475: IP: tableid=0, s=1.1.4.1 (local), d=3.3.3.3 (Serial1/0), routed via RIB
*Sep 15 11:53:45.475: IP: s=1.1.4.1 (local), d=3.3.3.3 (Serial1/0), len 100, sending.
R1 匹配默认路由把包发出 !
R2 : R2#debug ip packet
IP packet debugging is on
*Sep 15 11:53:46.191: IP: s=1.1.4.1 (Serial2/0), d=3.3.3.3 (Ethernet0/0), g=3.3.3.3, len 100, forward
*Sep 15 11:53:46.191: IP: s=1.1.4.1 (Serial2/0), d=3.3.3.3 (Ethernet0/0), len 100, encapsulation failed
R2显示封装失败, 验证了我们的思路. R2不知道目的IP ,也就根本没有进行ARP请求.
这里配置的default interface E0/0 跟
静态路由的逃出接口是有区别的, 静态路由的逃出接口在配置Ethernet的情况下,会执行ARP请求的 (静态也是解决此实验互通问题的一种方法).
在R2上加一条静态缺省,测试一下:
R2(config)#ip route 0.0.0.0 0.0.0.0 E0/0
R1#p 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/4 ms
OK ! 这里第一个不通的包, 就是执行ARP解析超时! 问题解决!
下面我们去掉R2的缺省路由, 改一下策略配置, 来解决此实验互通问题 :
R2(config)#no ip route 0.0.0.0 0.0.0.0 e0/0
R2(config)#route-map to-R3 permit 20
R2(config-route-map)#no set default interface e0/0
R2(config-route-map)#set ip next-hop 33.1.1.3
$ 明确指定下一跳为 R3的E0/0地址
测试一下 :
R1#ping
Target IP address: 3.3.3.3
Source address or interface: 1.1.4.1
Packet sent with a source address of 1.1.4.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/29/32 ms
目的< 3 >分析 :
( 1 ) set default interface ;
应用策略后 ,它的优先级低于精确匹配路由 ,但高于默认路由 ! 路由器转发数据包时,先查路由表,再没有精确匹配的路由条目时,才启用此策略转发 !
验证 : R2加一条3.3.3.0/24 的静态, R1的1.1.1.1 发包, 查看R2 测试信息 :
R2(config)#ip route 3.3.3.0 255.255.255.0 s1/0
R2#debug ip policy
Policy routing debugging is on
*Sep 15 12:45:58.539: IP: s=1.1.1.1 (Serial2/0), d=3.3.3.3 (Serial1/0), len 100, policy rejected -- normal forwarding
策略否决 ,按路由表( 精确匹配 )正常转发 !!!
R2去掉3.3.3.0/24的静态, 改成静态缺省 ,R1的1.1.1.1发包, 查看R2 测试信息 :
R2(config)#ip route 0.0.0.0 0.0.0.0 s1/0
*Sep 15 12:56:19.931: IP: s=1.1.1.1 (Serial2/0), d=3.3.3.3, len 100, policy match
*Sep 15 12:56:19.931: IP: route map to-R3, item 10, permit
*Sep 15 12:56:19.931: IP: s=1.1.1.1 (Serial2/0), d=3.3.3.3 (Serial1/0), len 100, policy routed
*Sep 15 12:56:19.931: IP: Serial2/0 to Serial1/0 3.3.3.3
根据策略路由转发!!!
( 2 ) set interface和set ip next-hop
在应用策略后 ,其优先级别
是一样的. 它们都优先于路由表 ,即使路由表里没有对应的路由条目 ,只用策略照样正常转发数据 !
其区别就在于,
set interface 是针对接口 ,而且是本地接口 !
而set ip next-hop 是针对精确地址 , 注意
这里是对端的 ( 下一跳 )地址 !
实验目的< 1 >已经验证了其优先级别 ,不再多说 .
各位多指正 ! ! ! 谢谢
|