【拓扑和软件】

本文实验采用的交换机是H3C模拟器,下载地址如下:
http://forum.h3c.com/forum.php?
mod=viewthread&tid=109740&highlight=H3C%E6%A8%A1%E6%
8B%9F%E5%99%A8 有兴趣的朋 友可以在论坛上去下载
【组网需求】
R1,R2,R3,R4之间跑动态路由
从R1的S0/6/3进来的数据包
长度为1-63的走192.168.12.2
长度为64-10000的走192.168.13.2
其他长度的报文按路由表查找
【配置信息】
R1:
interface Serial0/6/0
link-protocol ppp
ip address 192.168.12.1 255.255.255.0
#
interface Serial0/6/1
link-protocol ppp
ip address 192.168.13.1 255.255.255.0
#
interface Serial0/6/2
link-protocol ppp
#
interface Serial0/6/3
link-protocol ppp
ip address 172.16.15.1 255.255.255.0
ip policy-based-route lab1
#
#
ospf 1
area 0.0.0.0
network 192.168.12.0 0.0.0.255
network 192.168.13.0 0.0.0.255
network 172.16.15.0 0.0.0.255
#
policy-based-route lab1 permit node 10
if-match packet-length 1 63
apply ip-address next-hop 192.168.12.2
policy-based-route lab1 permit node 20
if-match packet-length 64 10000
apply ip-address next-hop 192.168.13.2
#
R2:
interface Serial0/6/0
link-protocol ppp
ip address 192.168.12.2 255.255.255.0
#
interface Serial0/6/1
link-protocol ppp
ip address 192.168.24.1 255.255.255.0
#
ospf 1
area 0.0.0.0
network 192.168.24.0 0.0.0.255
network 192.168.12.0 0.0.0.255
R3:
interface Serial0/6/0
link-protocol ppp
ip address 192.168.34.1 255.255.255.0
#
interface Serial0/6/1
link-protocol ppp
ip address 192.168.13.2 255.255.255.0
#
ospf 1
area 0.0.0.0
network 192.168.13.0 0.0.0.255
network 192.168.34.0 0.0.0.255
#
R4:
#
interface Serial0/6/0
link-protocol ppp
ip address 192.168.34.2 255.255.255.0
#
interface Serial0/6/1
link-protocol ppp
ip address 192.168.24.2 255.255.255.0
#
interface NULL0
#
interface LoopBack0
ip address 10.1.1.1 255.255.255.255
#
ospf 1
area 0.0.0.0
network 192.168.24.0 0.0.0.255
network 192.168.34.0 0.0.0.255
network 10.1.1.1 0.0.0.0
#
R5:
#
interface Serial0/6/3
link-protocol ppp
ip address 172.16.15.2 255.255.255.0
ip route-static 0.0.0.0 0.0.0.0 172.16.15.1
【验证】
在R5上ping 10.1.1.1 在R1上开启debugging 信息
<R5>ping 10.1.1.1
PING 10.1.1.1: 56 data bytes, press CTRL_C to
break
Reply from 10.1.1.1: bytes=56 Sequence=1 ttl=253
time=4 ms
Reply from 10.1.1.1: bytes=56 Sequence=2 ttl=253
time=4 ms
Reply from 10.1.1.1: bytes=56 Sequence=3 ttl=253
time=10 ms
Reply from 10.1.1.1: bytes=56 Sequence=4 ttl=253
time=10 ms
Request time out
--- 10.1.1.1 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 4/7/10 ms
<R1>
*Feb 28 19:51:51:578 2013 R1 PBR/7/POLICY-ROUTING:IP
policy based routing success : POLICY_ROUTEMAP :
lab1, Node : 20, next-hop : 192.168.13.2
*Feb 28 19:51:51:781 2013 R1 PBR/7/POLICY-ROUTING:IP
policy based routing success : POLICY_ROUTEMAP :
lab1, Node : 20, next-hop : 192.168.13.2
*Feb 28 19:51:51:984 2013 R1 PBR/7/POLICY-ROUTING:IP
policy based routing success : POLICY_ROUTEMAP :
lab1, Node : 20, next-hop : 192.168.13.2
*Feb 28 19:51:52:187 2013 R1 PBR/7/POLICY-ROUTING:IP
policy based routing success : POLICY_ROUTEMAP :
lab1, Node : 20, next-hop : 192.168.13.2
*Feb 28 19:51:52:406 2013 R1 PBR/7/POLICY-ROUTING:IP
policy based routing success : POLICY_ROUTEMAP :
lab1, Node : 20, next-hop : 192.168.13.2
<R5>
如上,如果按照R1的路由表,都应当走 192.168.12.2 ,但是因为有策略路由,下一跳指向了192.168.13.2 实验完成
<R1>dis ip ro
Routing Tables: Public
Destinations : 14 Routes : 15
Destination/Mask Proto Pre Cost NextHop Interface
10.1.1.1/32 OSPF 10 3124 192.168.12.2 S0/6/0
OSPF 10 3124 192.168.13.2 S0/6/1