A-A+

思科同时匹配源和目标地址的策略路由配置测试实验

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

这个实验,采用并不复杂的组网形式,来验证思科路由器在同时匹配目标地址和源的情况下,进行策略路由配置的功能。具体命令如下。

1.测试拓扑:

2.基本配置:

  1. R1:  
  2. interface FastEthernet0/0  
  3.  ip address 12.1.1.1 255.255.255.0  
  4.  no shutdown  
  5. interface Loopback0  
  6.  ip address 1.1.1.1 255.255.255.0  
  7. R2:  
  8. interface Ethernet0/0  
  9.  ip address 12.1.1.2 255.255.255.0  
  10.  no shutdown  
  11. !  
  12. interface Ethernet0/1  
  13.  ip address 23.1.1.2 255.255.255.0  
  14.  no shutdown  
  15. !  
  16. interface Ethernet0/2  
  17.  ip address 24.1.1.2 255.255.255.0  
  18.  no shutdown  
  19. R3:  
  20. interface FastEthernet0/0  
  21.  ip address 23.1.1.3 255.255.255.0  
  22.  no shutdown  
  23. !  
  24. interface FastEthernet0/1  
  25.  ip address 50.1.1.3 255.255.255.0  
  26.  no shutdown  
  27. R4:  
  28. interface FastEthernet0/0  
  29.  ip address 24.1.1.4 255.255.255.0  
  30.  no shutdown  
  31. !  
  32. interface FastEthernet0/1  
  33.  ip address 50.1.1.4 255.255.255.0  
  34.  no shutdown  
  35.   
  36.   
  37. R5:  
  38. interface Loopback0  
  39.  ip address 5.5.5.5 255.255.255.0  
  40. !  
  41. interface FastEthernet0/0  
  42.  ip address 50.1.1.5 255.255.255.0  
  43.  no shutdown  

3.静态路由配置:

  1. R1:  
  2. ip route 0.0.0.0 0.0.0.0 12.1.1.2  
  3. R2:  
  4. ip route 0.0.0.0 0.0.0.0 23.1.1.3  
  5. ip route 1.1.1.0 255.255.255.0 12.1.1.1  
  6. R3:  
  7. ip route 5.5.5.0 255.255.255.0 50.1.1.5  
  8. ip route 12.1.1.0 255.255.255.0 23.1.1.2  
  9. R4:  
  10. ip route 1.1.1.0 255.255.255.0 24.1.1.2  
  11. ip route 5.5.5.0 255.255.255.0 50.1.1.5  
  12. R5:  
  13. ip route 0.0.0.0 0.0.0.0 50.1.1.3  
  14. ip route 1.1.1.0 255.255.255.0 50.1.1.4  

4.R2策略路由配置:

A.配置访问控制列表,匹配流量:

access-list 110 permit ip 1.1.1.0 0.0.0.255 5.5.5.0 0.0.0.255

B.配置route-map,匹配流量后,设置下一跳

  1. route-map net5 permit 10  
  2.  match ip address 110  
  3.  set ip next-hop 24.1.1.4  
  4. !  
  5. route-map net5 permit 20  

C.在访问控制列表对应流量的进入接口应用route-map

interface Ethernet0/0

ip policy route-map net5

5.效果测试:

A.R1直接traceroute 5.5.5.5 ,这时的源地址为12.1.1.1

  1. R1#traceroute 5.5.5.5                       
  2. Type escape sequence to abort.  
  3. Tracing the route to 5.5.5.5  
  4.   
  5.   1 12.1.1.2 36 msec 80 msec 44 msec  
  6.   2 23.1.1.3 92 msec 96 msec 60 msec  
  7.   3 50.1.1.5 160 msec *  184 msec  
  8. R1#  

-----可以看到R2根据默认路由配置,将去往5.5.5.5的数据包下一跳扔给了R3。

B.R1指定源地址为1.1.1.1来traceroute 5.5.5.5

  1. R1#traceroute 5.5.5.5 source 1.1.1.1  
  2.   
  3. Type escape sequence to abort.  
  4. Tracing the route to 5.5.5.5  
  5.   
  6.   1 12.1.1.2 44 msec 100 msec 56 msec  
  7.   2 24.1.1.4 68 msec 64 msec 96 msec  
  8.   3 50.1.1.5 124 msec *  140 msec  
  9. R1#  

----可以看到,R2根据策略路由配置,将源地址为1.1.1.1目标地址为5.5.5.5的下一跳扔给了R4。

标签:

给我留言