A-A+

双ISP接入,实现负载负载均衡相互备份和策略路由

2016年02月19日 站长资讯 暂无评论

实验环境:

R1上联线路分别为R2和R3,R2、R3、R4通过OSPF进行通信。

实验目的:

让C1默认通过R1与R2的连接访问R4,如果R1与R2的线路中断,那则通过R1与R3的线路访问R4 .

让C2默认通过R1与R3的连接访问R4,如果R1与R3的线路中断,那则通过R1与R2的线路访问R4 .

配置如下:

  1. R1(config-if)#do sh run  
  2. Building configuration...  
  3.   
  4. Current configuration : 2055 bytes  
  5. !  
  6. version 12.4  
  7. service timestamps debug datetime msec  
  8. service timestamps log datetime msec  
  9. no service password-encryption  
  10. !  
  11. hostname R1  
  12. !  
  13. boot-start-marker  
  14. boot-end-marker  
  15. !  
  16. !  
  17. no aaa new-model  
  18. memory-size iomem 5  
  19. ip cef  
  20. !  
  21. !  
  22. !  
  23. !  
  24. no ip domain lookup  
  25. ip domain name lab.local  
  26. !  
  27. multilink bundle-name authenticated  
  28. !  
  29. !  
  30. !  
  31. !  
  32. !  
  33. !  
  34. !  
  35. !  
  36. !  
  37. !  
  38. !  
  39. interface FastEthernet0/0  
  40. ip address 10.10.10.2 255.255.255.0  
  41. ip nat outside  
  42. ip virtual-reassembly  
  43. shutdown  
  44. duplex auto  
  45. speed auto  
  46. !  
  47. interface FastEthernet0/1  
  48. ip address 192.168.1.2 255.255.255.0  
  49. ip nat outside  
  50. ip virtual-reassembly  
  51. duplex auto  
  52. speed auto  
  53. !  
  54. interface FastEthernet1/0  
  55. ip address 40.40.40.1 255.255.255.0 secondary  
  56.   
  57.   
  58. ip address 30.30.30.1 255.255.255.0  
  59. ip nat inside  
  60. ip virtual-reassembly  
  61. ip policy route-map load  

注:将策略路由load,应用到访f1/0口

  1. duplex auto  
  2. speed auto  
  3. !  
  4. ip route 0.0.0.0 0.0.0.0 192.168.1.1  
  5. ip route 0.0.0.0 0.0.0.0 10.10.10.1  
  6. !  
  7. !  
  8. no ip http server  
  9. no ip http secure-server  
  10. ip nat inside source route-map test1 interface FastEthernet0/0 overload  

注:如果是去往R2,转换出口为fa0/0口,正常去往R2时就拿fa0/0公网地址进行转换

ip nat inside source route-map test2 interface FastEthernet0/1 overload

注:如果是去往R2,转换出口为FA0/1口,作用就是当去往R2主接口FA0/0 down掉,这时只有拿FA0/1接口的公网地址进行转换。

ip nat inside source route-map test3 interface FastEthernet0/1 overload

注:如果是去往R3,转换出口为fa0/1口,正常去往R3时就拿fa0/1公网地址进行转换

ip nat inside source route-map test4 interface FastEthernet0/0 overload

注:如果是去往R3,转换出口为FA0/0口,作用就是当去往R3主接口FA0/1 down掉,这时只有拿FA0/0接口的公网地址进行转换。

access-list 1 permit 30.30.30.0 0.0.0.255

注:允许30.30.30.0网段访问。

access-list 2 permit 40.40.40.0 0.0.0.255

注:允许40.40.40.0网段访问。

  1. !  
  2. !  
  3. route-map load permit 10  
  4. match ip address 1  
  5. set interface FastEthernet0/0  
  6. set default interface FastEthernet0/1  

注:策略路由名为load,匹配去往R2的,设置出口为FA0/0口(电信出口),如果FA0/0 DOWN掉,设置默认出口为FA0/1口(与R3出口)。

!

route-map load permit 20

match ip address 2

set interface FastEthernet0/1

set default interface FastEthernet0/0

注:如果没有匹配10,则往下匹配20,匹配去往R3网段的地址,设置出口为FA0/1口,如果FA0/1 DOWN掉,设置默认出口为FA0/0口(与R2出口)。

!

route-map test4 permit 10

match ip address 2

match interface FastEthernet0/0

注:即要匹配去往R3的地址段,也要匹配出口为FA0/0口。同时满足这两个条件,就给它做nat转换。这条语句主要是做备份用的,当fa0/1口DOWN掉时,这里就只有fa0/0口可以用

!

route-map test2 permit 10

match ip address 1

match interface FastEthernet0/1

注:即要匹配去往R2的地址段,也要匹配出口为FA0/1口。同时满足这两个条件,就给它做nat转换。这条语句主要是做备份用的,当fa0/0口DOWN掉时,这里就只有fa0/1口可以用

!

route-map test3 permit 10

match ip address 2

match interface FastEthernet0/1

注:即要匹配去往R3的地址段,也要匹配出口为FA0/1口。同时满足这两个条件,就给它做nat转换。

!

route-map test1 permit 10

match ip address 1

match interface FastEthernet0/0

注:即要匹配去往R2的地址段,也要匹配出口为FA0/0(电信出口)。同时满足这两个条件,就给它做nat转换。

  1. !  
  2. !  
  3. !  
  4. !  
  5. control-plane  
  6. !  
  7. !  
  8. !  
  9. line con 0  
  10. exec-timeout 0 0  
  11. privilege level 15  
  12. logging synchronous  
  13. line aux 0  
  14. exec-timeout 0 0  
  15. privilege level 15  
  16. logging synchronous  
  17. line vty 0 4  
  18. login  
  19. !  
  20. !  
  21. end  
标签:

给我留言