A-A+

基于报文地址的策略路由配置的方法/示例

2015年11月23日 站长资讯 暂无评论

本次实验的拓扑图如下,采用5台华三H3C路由器/交换机来完成这次组网:

本文实验采用的交换机是H3C模拟器,有兴趣的朋友可以在H3C官方网站的技术论坛上去下载.

【组网需求】

普通的报文转发是依据报文的目的地址查询转发表来实现的。策略路由支持基于acl包过滤、地址长度等信息,灵活地指定路由。而acl报文过滤则可以根据报文的源ip、目的ip、协议、端口号、优先级、tos、时间段、vpn等各种丰富的信息将报文分类,然后控制将这些报文按照不同的路由转发出去。本实验难通过源IP来控制报文的下一跳。

策略路由分类

接口策略路由

接口策略路由只对转发的报文起作用,对本地产生的报文(比如本地的ping报文)不起作用。而本地策略路由只对本地产生的报文起作用,对转发的报文不起作用。
接口策略路由配置在接口视图下。

本地策略路由

本地产生的报文的策略路由配置在系统视图下。

注意:组播策略路由只支持转发的报文,不对路由器本机产生的报文进行策略路由。

R5上有两个网段100.100.100.100,200.200.200.200,用Loop0和loop1代替,去R4的10.1.1.1 在经R1时默认的下一跳有两个,但是为了演示PBR的用法,现根据不同的源地址来给不同的下一跳。

【配置信息】

  1. R1:  
  2.    
  3. acl number 2000   
  4.  rule 0 permit source 100.100.100.100 0  
  5. acl number 2001  
  6.  rule 0 permit source 200.200.200.200 0  
  7. #  
  8. interface Serial0/6/0  
  9.  link-protocol ppp  
  10.  ip address 192.168.12.1 255.255.255.0  
  11. #  
  12. interface Serial0/6/1  
  13.  link-protocol ppp  
  14.  ip address 192.168.13.1 255.255.255.0  
  15. #  
  16. interface Serial0/6/2  
  17.  link-protocol ppp  
  18. #  
  19. interface Serial0/6/3  
  20.  link-protocol ppp  
  21.  ip address 172.16.15.1 255.255.255.0  
  22.  ip policy-based-route 123  
  23.    
  24. #                 
  25. ospf 1  
  26.  default-route-advertise always  
  27.  area 0.0.0.0  
  28.   network 192.168.12.0 0.0.0.255  
  29.   network 192.168.13.0 0.0.0.255  
  30.   network 172.16.15.0 0.0.0.255  
  31. #  
  32. policy-based-route 123 permit node 10  
  33.    if-match acl 2000  
  34.    apply ip-address next-hop 192.168.12.2  
  35. policy-based-route 123 permit node 20  
  36.    if-match acl 2001  
  37.    apply ip-address next-hop 192.168.13.2  
  38. #  
  39.  ip route-static 100.100.100.100 255.255.255.255 172.16.15.2  
  40.  ip route-static 200.200.200.200 255.255.255.255 172.16.15.2  
  41.  http://www.xiaoxiongboke.com   
  42. R2:  
  43.    
  44. interface Serial0/6/0  
  45.  link-protocol ppp  
  46.  ip address 192.168.12.2 255.255.255.0  
  47. #  
  48. interface Serial0/6/1  
  49.  link-protocol ppp  
  50.  ip address 192.168.24.1 255.255.255.0  
  51.    
  52. #  
  53. ospf 1  
  54.  area 0.0.0.0  
  55.   network 192.168.24.0 0.0.0.255  
  56.   network 192.168.12.0 0.0.0.255  
  57.    
  58. R3:  
  59.    
  60. interface Serial0/6/0  
  61.  link-protocol ppp  
  62.  ip address 192.168.34.1 255.255.255.0  
  63. #  
  64. interface Serial0/6/1  
  65.  link-protocol ppp  
  66.  ip address 192.168.13.2 255.255.255.0  
  67. #  
  68. ospf 1  
  69.  area 0.0.0.0  
  70.   network 192.168.13.0 0.0.0.255  
  71.   network 192.168.34.0 0.0.0.255  
  72. #  
  73.    
  74. R4:  
  75. #  
  76. interface Serial0/6/0  
  77.  link-protocol ppp  
  78.  ip address 192.168.34.2 255.255.255.0  
  79. #  
  80. interface Serial0/6/1  
  81.  link-protocol ppp  
  82.  ip address 192.168.24.2 255.255.255.0  
  83.    
  84. #  
  85. interface NULL0  
  86. #  
  87. interface LoopBack0  
  88.  ip address 10.1.1.1 255.255.255.255  
  89. #  
  90. ospf 1  
  91.  area 0.0.0.0  
  92.   network 192.168.24.0 0.0.0.255  
  93.   network 192.168.34.0 0.0.0.255  
  94.   network 10.1.1.1 0.0.0.0  
  95. #  
  96.    
  97. R5:  
  98.    
  99. #  
  100. interface Serial0/6/3  
  101.  link-protocol ppp  
  102.  ip address 172.16.15.2 255.255.255.0  
  103. #  
  104. interface NULL0  
  105. #  
  106. interface LoopBack0  
  107.  ip address 100.100.100.100 255.255.255.255  
  108. #  
  109. interface LoopBack1  
  110.  ip address 200.200.200.200 255.255.255.255  
  111.    
  112.  ip route-static 0.0.0.0 0.0.0.0 172.16.15.1  

【验证】

如下,去10.1.1.1有两个下一跳,路由表中显示192.168.12.2是默认的下一跳,现用PBR来干预下一跳的指向

  1. [R1]dis ip ro  
  2. Routing Tables: Public  
  3.         Destinations : 16       Routes : 17  
  4.    
  5. Destination/Mask    Proto  Pre  Cost         NextHop         Interface  
  6.    
  7. 10.1.1.1/32         OSPF   10   3124         192.168.12.2    S0/6/0  
  8.                     OSPF   10   3124         192.168.13.2    S0/6/1  

1、先在R1打开调试开关

  1. <R1>t d  
  2. % Current terminal debugging is on  
  3.    
  4. <R1>t m  
  5. % Current terminal monitor is on  
  6.    
  7. <R1>deb  
  8. <R1>debugging ip p  
  9. <R1>debugging ip packet  
  10. <R1>debugging ip policy-based-route  

2、用R5带源地址Ping

  1. <R5>ping -a  100.100.100.100 10.1.1.1  
  2.   PING 10.1.1.1: 56  data bytes, press CTRL_C to break  
  3.     Reply from 10.1.1.1: bytes=56 Sequence=1 ttl=253 time=10 ms  
  4.     Reply from 10.1.1.1: bytes=56 Sequence=2 ttl=253 time=4 ms  
  5.     Reply from 10.1.1.1: bytes=56 Sequence=3 ttl=253 time=20 ms  
  6.     Reply from 10.1.1.1: bytes=56 Sequence=4 ttl=253 time=1 ms  
  7.     Reply from 10.1.1.1: bytes=56 Sequence=5 ttl=253 time=10 ms  
  8.    
  9.   --- 10.1.1.1 ping statistics ---  
  10.     5 packet(s) transmitted  
  11.     5 packet(s) received  
  12.     0.00% packet loss  
  13.     round-trip min/avg/max = 1/9/20 ms  
  14.    
  15. <R5>  
  16. <R5>ping -a  200.200.200.200 10.1.1.1  
  17.   PING 10.1.1.1: 56  data bytes, press CTRL_C to break  
  18.     Request time out  
  19.     Reply from 10.1.1.1: bytes=56 Sequence=2 ttl=253 time=10 ms  
  20.     Reply from 10.1.1.1: bytes=56 Sequence=3 ttl=253 time=1 ms  
  21.     Reply from 10.1.1.1: bytes=56 Sequence=4 ttl=253 time=26 ms  
  22.     Reply from 10.1.1.1: bytes=56 Sequence=5 ttl=253 time=1 ms  
  23.    
  24.   --- 10.1.1.1 ping statistics ---  
  25.     5 packet(s) transmitted  
  26.     4 packet(s) received  
  27.     20.00% packet loss  
  28.     round-trip min/avg/max = 1/9/26 ms  

3、R1出现如下的调试信息:

  1. [R1-Serial0/6/3]  
  2. *Feb 28 22:45:14:781 2013 R1 PBR/7/POLICY-ROUTING:IP policy based routing success : POLICY_ROUTEMAP : 123, Node : 10, next-hop : 192.168.12.2  
  3. *Feb 28 22:45:25:00 2013 R1 PBR/7/POLICY-ROUTING:IP policy based routing success : POLICY_ROUTEMAP : 123, Node : 20, next-hop : 192.168.13.2  

不同的源地址Ping过来,下一跳指向不同,这次配置的实验就算是完成了。

标签:

给我留言