【组网需求】
 
1、XX市某公司,分部在区县,总部在主城区,他们之间通过两条E1专线相连,其业务在这两条线路之间负载分担,现A业务流量太大,故将两条专线改成主备方式,专线1作为A业
 
务的专用链路及其他业务的备份,专线2作为其他业务的主链路及A业务的备份。
 
2、拓扑和软件
 
 

本文实验采用的交换机是H3C模拟器,下载地址如下: http://forum.h3c.com/forum.php? mod=viewthread&tid=109740&highlight=H3C%E6%A8%A1%E6% 8B%9F%E5%99%A8 有兴趣的朋 友可以在论坛上去下载,里面有非常详细的使用说明以及自定义拓扑的方法。
 
3、组网需求
实验中假设的一个Loopback地址在实际应用中可以看成是一个网段。
假设192.168.36.1只和192.168.20.1通信
192.168.37.1只和192.168.21.1
 
当源地址是192.168.36.1去192.168.20.1时,经R2时下一跳是172.16.1.1
192.168.37.1去往192.168.21.1下一跳为172.16.1.5
 
R3上同理作回包的策略路由
 
 
 
 
 
【配置】
 
R1:
 
 
interface Serial0/2/0
 link-protocol ppp
 ip address 172.16.1.14 255.255.255.252
#
interface Serial0/2/1
 link-protocol ppp
#
interface NULL0
#
interface LoopBack0
 ip address 192.168.0.1 255.255.255.255
#
interface LoopBack10
 ip address 192.168.36.1 255.255.255.255
#
interface LoopBack11
 ip address 192.168.37.1 255.255.255.255
#
 
 
#
ospf 1
 area 0.0.0.0
  network 172.16.1.12 0.0.0.3
  network 192.168.36.1 0.0.0.0
  network 192.168.37.1 0.0.0.0
 
R2:
 
 
 
acl number 3000 
 rule 0 permit ip source 192.168.36.1 0 destination 192.168.20.1 0
#
interface Serial0/2/0
 link-protocol ppp
 ip address 172.16.1.2 255.255.255.252
#
interface Serial0/2/1
 link-protocol ppp
 ip address 172.16.1.6 255.255.255.252
#
interface Serial0/2/2
 link-protocol ppp
 ip address 172.16.1.13 255.255.255.252
 ip policy-based-route R1-to-ser
#
interface NULL0
#
interface LoopBack0
 ip address 192.168.0.2 255.255.255.255
 
 
 
 
 
ospf 1
 area 0.0.0.0
  network 172.16.1.12 0.0.0.3
  network 172.16.1.0 0.0.0.3
  network 172.16.1.4 0.0.0.3
#
policy-based-route R1-to-ser permit node 10
   if-match acl 3000
   apply ip-address next-hop 172.16.1.1
policy-based-route R1-to-ser permit node 20
   apply ip-address next-hop 172.16.1.5
 
 
R3:
 
acl number 3000 
 rule 0 permit ip source 192.168.20.1 0 destination 192.168.36.1 0
#
interface Ethernet0/1/0
 port link-mode route
#
interface Serial0/2/0
 link-protocol ppp
 ip address 172.16.1.1 255.255.255.252
#
interface Serial0/2/1
 link-protocol ppp
 ip address 172.16.1.5 255.255.255.252
#
interface Serial0/2/2
 link-protocol ppp
 ip address 172.16.1.9 255.255.255.252
 ip policy-based-route ser-to-R1
#
interface Serial0/2/3
 link-protocol ppp
#
interface NULL0
#               
interface LoopBack0
 ip address 192.168.0.3 255.255.255.255
 
ospf 1
 area 0.0.0.0
  network 172.16.1.0 0.0.0.3
  network 172.16.1.4 0.0.0.3
  network 172.16.1.8 0.0.0.3
#
policy-based-route ser-to-R1 permit node 10
   if-match acl 3000
   apply ip-address next-hop 172.16.1.2
policy-based-route ser-to-R1 permit node 20
   apply ip-address next-hop 172.16.1.6
 
R4
 
interface Serial0/2/2
 link-protocol ppp
 ip address 172.16.1.10 255.255.255.252
#
interface Serial0/2/3
 link-protocol ppp
#
interface NULL0
#
interface LoopBack0
 ip address 192.168.0.4 255.255.255.255
#
interface LoopBack10
 ip address 192.168.20.1 255.255.255.255
#               
interface LoopBack11
 ip address 192.168.21.1 255.255.255.255
 
ospf 1
 area 0.0.0.0
  network 172.16.1.8 0.0.0.3
  network 192.168.20.1 0.0.0.0
  network 192.168.21.1 0.0.0.0
 
【测试】
 
 
 
<R1>ping -a 192.168.36.1 192.168.20.1
  PING 192.168.20.1: 56  data bytes, press CTRL_C to break
    Reply from 192.168.20.1: bytes=56 Sequence=1 ttl=253 time=4 ms
    Reply from 192.168.20.1: bytes=56 Sequence=2 ttl=253 time=10 ms
    Reply from 192.168.20.1: bytes=56 Sequence=3 ttl=253 time=16 ms
    Reply from 192.168.20.1: bytes=56 Sequence=4 ttl=253 time=20 ms
    Reply from 192.168.20.1: bytes=56 Sequence=5 ttl=253 time=1 ms
 
  --- 192.168.20.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 1/10/20 ms
 
<R1>ping -a 192.168.37.1 192.168.20.1
  PING 192.168.20.1: 56  data bytes, press CTRL_C to break
    Reply from 192.168.20.1: bytes=56 Sequence=1 ttl=253 time=10 ms
    Reply from 192.168.20.1: bytes=56 Sequence=2 ttl=253 time=10 ms
    Reply from 192.168.20.1: bytes=56 Sequence=3 ttl=253 time=20 ms
    Reply from 192.168.20.1: bytes=56 Sequence=4 ttl=253 time=16 ms
    Reply from 192.168.20.1: bytes=56 Sequence=5 ttl=253 time=25 ms
 
  --- 192.168.20.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 10/16/25 ms
 
 
 
在R1上Ping第一次,出现如下的第一条信息
 
ping 第二次时,出现如下的第二条信息
 
[R2-Serial0/2/2]
*Mar  4 23:07:43:328 2013 R2 PBR/7/POLICY-ROUTING:IP policy based routing success : POLICY_ROUTEMAP : R1-to-ser, Node : 10, next-hop : 172.16.1.1             
 
      匹配node 10
*Mar  4 23:08:25:94 2013 R2 PBR/7/POLICY-ROUTING:IP policy based routing success : POLICY_ROUTEMAP : R1-to-ser, Node : 20, next-hop : 172.16.1.5              
 
              匹配node 20
 
 
 
 
 
断一条线路
 
 
[R2-Serial0/2/2]int s0/2/0
[R2-Serial0/2/0]shut
[R2-Serial0/2/0]
%Mar  4 23:20:38:562 2013 R2 IFNET/4/UPDOWN:
 Line protocol on the interface Serial0/2/0 is DOWN 
%Mar  4 23:20:38:562 2013 R2 IFNET/4/UPDOWN:
 Protocol PPP IPCP on the interface Serial0/2/0 is DOWN 
%Mar  4 23:20:38:562 2013 R2 RM/3/RMLOG:OSPF-NBRCHANGE: Process 1, Neighbor 172.16.1.1(Serial0/2/0) from Full to Down
[R2-Serial0/2/0]
[R2-Serial0/2/0]qu
[R2]qu
<R2>t d
% Current terminal debugging is on
 
<R2>t m    
% Current terminal monitor is on
 
R1上再Ping
 
 
<R1>ping -a 192.168.36.1 192.168.20.1
  PING 192.168.20.1: 56  data bytes, press CTRL_C to break
    Reply from 192.168.20.1: bytes=56 Sequence=1 ttl=253 time=14 ms
    Reply from 192.168.20.1: bytes=56 Sequence=2 ttl=253 time=20 ms
    Reply from 192.168.20.1: bytes=56 Sequence=3 ttl=253 time=10 ms
    Reply from 192.168.20.1: bytes=56 Sequence=4 ttl=253 time=20 ms
    Reply from 192.168.20.1: bytes=56 Sequence=5 ttl=253 time=4 ms
 
  --- 192.168.20.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 4/13/20 ms
 
 
<R2>deb
<R2>debugging ip p 
<R2>debugging ip packet
<R2>debugging ip policy-based-route
<R2>
*Mar  4 23:21:13:453 2013 R2 PBR/7/POLICY-ROUTING:POLICY_ROUTEMAP : R1-to-ser, Node : 10, Packet satisfied if_match clause. But next-hop 172.16.1.1 
 
unreachable.     匹配成功,但是下一跳不可达,所以走另一个下一跳172.16.1.5 达到线路备份的
*Mar  4 23:21:13:672 2013 R2 PBR/7/POLICY-ROUTING:POLICY_ROUTEMAP : R1-to-ser, Node : 10, Packet satisfied if_match clause. But next-hop 172.16.1.1 
 
unreachable.
*Mar  4 23:21:13:875 2013 R2 PBR/7/POLICY-ROUTING:POLICY_ROUTEMAP : R1-to-ser, Node : 10, Packet satisfied if_match clause. But next-hop 172.16.1.1 
 
unreachable.
*Mar  4 23:21:14:94 2013 R2 PBR/7/POLICY-ROUTING:POLICY_ROUTEMAP : R1-to-ser, Node : 10, Packet satisfied if_match clause. But next-hop 172.16.1.1 
 
unreachable.
*Mar  4 23:21:14:297 2013 R2 PBR/7/POLICY-ROUTING:POLICY_ROUTEMAP : R1-to-ser, Node : 10, Packet satisfied if_match clause. But next-hop 172.16.1.1 
 
unreachable.
<R2>
<R2>sy
System View: return to User View with Ctrl+Z.
 
再将端口启用
[R2-Serial0/2/0]undo shut
[R2-Serial0/2/0]
%Mar  4 23:22:10:219 2013 R2 IFNET/4/UPDOWN:
 Line protocol on the interface Serial0/2/0 is UP 
%Mar  4 23:22:10:219 2013 R2 IFNET/4/UPDOWN:
 Protocol PPP IPCP on the interface Serial0/2/0 is UP dis th
#
interface Serial0/2/0
 link-protocol ppp
 ip address 172.16.1.2 255.255.255.252 
#
return
[R2-Serial0/2/0]
R1上再ping
 
<R1>ping -a 192.168.36.1 192.168.20.1
  PING 192.168.20.1: 56  data bytes, press CTRL_C to break
    Request time out
    Reply from 192.168.20.1: bytes=56 Sequence=2 ttl=253 time=26 ms
    Reply from 192.168.20.1: bytes=56 Sequence=3 ttl=253 time=26 ms
    Reply from 192.168.20.1: bytes=56 Sequence=4 ttl=253 time=4 ms
    Reply from 192.168.20.1: bytes=56 Sequence=5 ttl=253 time=1 ms
 
  --- 192.168.20.1 ping statistics ---
    5 packet(s) transmitted
    4 packet(s) received
    20.00% packet loss
    round-trip min/avg/max = 1/14/26 ms
 
 
%Mar  4 23:22:18:31 2013 R2 RM/3/RMLOG:OSPF-NBRCHANGE: Process 1, Neighbor 172.16.1.1(Serial0/2/0) from Loading to Full
*Mar  4 23:22:22:500 2013 R2 PBR/7/POLICY-ROUTING:IP policy based routing success  : POLICY_ROUTEMAP : R1-to-ser, Node : 10, next-hop : 172.16.1.1    再次匹
 
配成功
[R2-Serial0/2/0]
[R2-Serial0/2/0]