A-A+

两台路由器的BGP实战策略路由分发需求实战方案设计

2016年01月04日 站长资讯 暂无评论

R1和R2有两根线路相连,使用BGP,R1有两组路由,192.168.1.0/24和192.168.2.0/24,当两根线都通的状态下,两组路由流量分散平衡在两个线路上,当其中任意一根断的情况下,只通192.168.1.0/24流量。

方法1

【R1配置】

  1. interface Loopback0  
  2. ip address 1.1.1.1 255.255.255.255  
  3. !  
  4. interface Loopback1  
  5. ip address 192.168.1.1 255.255.255.0  
  6. !  
  7. interface Loopback2  
  8. ip address 192.168.2.1 255.255.255.0  
  9. !  
  10. interface FastEthernet0/0  
  11. ip address 10.2.12.1 255.255.255.0  
  12. duplex auto  
  13. speed auto  
  14. !  
  15. interface FastEthernet1/0  
  16. ip address 10.1.12.1 255.255.255.0  
  17. duplex auto  
  18. speed auto  
  19. !  
  20. router bgp 1  
  21. no bgp default ipv4-unicast  
  22. bgp log-neighbor-changes  
  23. neighbor 2.2.2.2 remote-as 2  
  24. neighbor 2.2.2.2 ebgp-multihop 2  
  25. neighbor 2.2.2.2 update-source Loopback0  
  26. neighbor 2.2.2.2 timers 1 3  
  27. neighbor 10.1.12.2 remote-as 2  
  28. neighbor 10.1.12.2 timers 1 3   
  29. neighbor 10.2.12.2 remote-as 2  
  30. neighbor 10.2.12.2 timers 1 3  
  31. maximum-paths 2  
  32. !  
  33. address-family ipv4  
  34.   neighbor 2.2.2.2 activate  
  35.   neighbor 10.1.12.2 activate  
  36.   neighbor 10.2.12.2 activate  
  37.   maximum-paths 2  
  38.   no auto-summary  
  39.   no synchronization  
  40.   network 192.168.1.0  
  41.   network 192.168.2.0  
  42. exit-address-family  
  43. !  
  44. no ip http server  
  45. no ip http secure-server  
  46. ip route 2.2.2.2 255.255.255.255 FastEthernet0/0 10.2.12.2  
  47. ip route 2.2.2.2 255.255.255.255 FastEthernet1/0 10.1.12.2  
  48. !  

【R2配置】

  1. !  
  2. ip sla monitor 1  
  3. type echo protocol ipIcmpEcho 10.2.12.1 source-interface FastEthernet0/0  
  4. ip sla monitor schedule 1 start-time now  
  5. ip sla monitor 2  
  6. type echo protocol ipIcmpEcho 10.1.12.1 source-interface FastEthernet1/0  
  7. ip sla monitor schedule 2 start-time now  
  8. !  
  9. !  
  10. track 1 rtr 1 reachability  
  11. !  
  12. track 2 rtr 2 reachability  
  13. !  
  14. track 3 list boolean and  
  15. object 1  
  16. object 2  
  17. !  
  18. !  
  19. interface Loopback0  
  20. ip address 2.2.2.2 255.255.255.255  
  21. !  
  22. interface FastEthernet0/0  
  23. ip address 10.2.12.2 255.255.255.0  
  24. duplex auto  
  25. speed auto  
  26. !  
  27. interface FastEthernet1/0  
  28. ip address 10.1.12.2 255.255.255.0  
  29. duplex auto  
  30. speed auto  
  31. !  
  32. router bgp 2  
  33. no bgp default ipv4-unicast  
  34. bgp log-neighbor-changes  
  35. neighbor 1.1.1.1 remote-as 1  
  36. neighbor 1.1.1.1 ebgp-multihop 2  
  37. neighbor 1.1.1.1 update-source Loopback0   
  38. neighbor 1.1.1.1 timers 1 3  
  39. neighbor 10.1.12.1 remote-as 1  
  40. neighbor 10.1.12.1 timers 1 3  
  41. neighbor 10.2.12.1 remote-as 1  
  42. neighbor 10.2.12.1 timers 1 3  
  43. maximum-paths 2  
  44. !  
  45. address-family ipv4  
  46.   neighbor 1.1.1.1 activate  
  47.   neighbor 1.1.1.1 distribute-list 1 in  
  48.   neighbor 10.1.12.1 activate  
  49.   neighbor 10.1.12.1 distribute-list 2 in  
  50.   neighbor 10.2.12.1 activate  
  51.   neighbor 10.2.12.1 distribute-list 2 in  
  52.   maximum-paths 2  
  53.   no auto-summary  
  54.   no synchronization  
  55. exit-address-family  
  56. !  
  57. no ip http server  
  58. no ip http secure-server  
  59. ip route 1.1.1.1 255.255.255.255 10.2.12.1 track 3  
  60. ip route 1.1.1.1 255.255.255.255 10.1.12.1 track 3  
  61. !  
  62. !  
  63. !  
  64. access-list 1 permit 192.168.2.0 0.0.0.255  
  65. access-list 2 permit 192.168.1.0 0.0.0.255  

方法2

R2修改方案,为企业方

  1. ip sla monitor 1  
  2. type echo protocol ipIcmpEcho 10.2.12.1 source-interface FastEthernet0/0  
  3. ip sla monitor schedule 1 start-time now  
  4. ip sla monitor 2  
  5. type echo protocol ipIcmpEcho 10.1.12.1 source-interface FastEthernet1/0  
  6. ip sla monitor schedule 2 start-time now  
  7. !  
  8. !  
  9. !  
  10. !  
  11. !  
  12. !  
  13. !  
  14. !  
  15. !  
  16. !  
  17. !  
  18. !  
  19. !  
  20. !  
  21. !  
  22. !  
  23. !  
  24. !  
  25. track 1 rtr 1 reachability  
  26. !  
  27. track 2 rtr 2 reachability  
  28. !  
  29. track 3 list boolean and  
  30. object 1  
  31. object 2  
  32. !  
  33. !  
  34. !  
  35. !  
  36. !  
  37. interface Loopback0  
  38. ip address 2.2.2.2 255.255.255.255  
  39. !  
  40. interface Loopback1  
  41. ip address 192.168.1.1 255.255.255.0  
  42. !  
  43. interface Loopback2  
  44. ip address 192.168.2.1 255.255.255.0  
  45. !  
  46. interface FastEthernet0/0  
  47. ip address 10.2.12.2 255.255.255.0  
  48. duplex auto  
  49. speed auto  
  50. !  
  51. interface FastEthernet1/0   
  52. ip address 10.1.12.2 255.255.255.0  
  53. duplex auto  
  54. speed auto  
  55. !  
  56. router bgp 2  
  57. no bgp default ipv4-unicast  
  58. bgp log-neighbor-changes  
  59. neighbor 1.1.1.1 remote-as 1  
  60. neighbor 1.1.1.1 ebgp-multihop 2  
  61. neighbor 1.1.1.1 update-source Loopback0  
  62. neighbor 1.1.1.1 timers 1 3  
  63. neighbor 10.1.12.1 remote-as 1  
  64. neighbor 10.1.12.1 timers 1 3  
  65. neighbor 10.2.12.1 remote-as 1  
  66. neighbor 10.2.12.1 timers 1 3  
  67. maximum-paths 2  
  68. !  
  69. address-family ipv4  
  70.   neighbor 1.1.1.1 activate  
  71.   neighbor 1.1.1.1 distribute-list 1 out  
  72.   neighbor 10.1.12.1 activate  
  73.   neighbor 10.1.12.1 distribute-list 2 out  
  74.   neighbor 10.2.12.1 activate  
  75.   neighbor 10.2.12.1 distribute-list 2 out  
  76.   maximum-paths 2  
  77.   no auto-summary  
  78.   no synchronization  
  79.   network 192.168.1.0  
  80.   network 192.168.2.0  
  81. exit-address-family  
  82. !   
  83. no ip http server  
  84. no ip http secure-server  
  85. ip route 1.1.1.1 255.255.255.255 10.2.12.1 track 3  
  86. ip route 1.1.1.1 255.255.255.255 10.1.12.1 track 3  
  87. !  
  88. !  
  89. !  
  90. access-list 1 permit 192.168.2.0 0.0.0.255  
  91. access-list 2 permit 192.168.1.0 0.0.0.255  

R1上down其中一个接口

R2提示

  1. R2#  
  2. *Mar  1 02:34:50.951: %BGP-5-ADJCHANGE: neighbor 10.1.12.1 Down BGP Notification sent  
  3. R2#  
  4. *Mar  1 02:34:50.955: %BGP-3-NOTIFICATION: sent to neighbor 10.1.12.1 4/0 (hold time expired) 0 bytes  
  5. R2#  
  6. R2#  
  7. R2#  
  8. R2#  
  9. R2#  
  10. *Mar  1 02:35:00.387: %TRACKING-5-STATE: 2 rtr 2 reachability Up->Down  
  11. *Mar  1 02:35:00.555: %TRACKING-5-STATE: 3 list boolean and Up->Down  
  12. R2#  
  13. *Mar  1 02:35:02.939: %BGP-3-NOTIFICATION: received from neighbor 1.1.1.1 4/0 (hold time expired) 0 bytes  
  14. R2#  
  15. *Mar  1 02:35:02.947: %BGP-5-ADJCHANGE: neighbor 1.1.1.1 Down BGP Notification received  

R1的路由表

R1#sh ip ro b

B 192.168.1.0/24 [20/0] via 10.2.12.2, 00:03:24

方法3

使用advertise-map来解决,但有些IOS不支持。

  1. (R1)  Config:  
  2. router bgp 1  
  3. no synchronization  
  4. bgp log-neighbor-changes  
  5. network 192.168.1.0  
  6. network 192.168.2.0  
  7. redistribute connected route-map redis_conn (目的是想将两条外线路由弄进bgp 路由表,方便后面的advertise-map检测这两条路由的存在性来决定是否要发布次要网段)  
  8. neighbor 12.1.1.2 remote-as 2  
  9. neighbor 12.1.1.2 update-source Serial1/0  
  10. neighbor 12.1.1.2 advertise-map dist_out2 exist-map line2(如果外线2正常,外线2的路由就会重分发进bgpl路由表,就通告出次要路由,此时如果2正常,且能从s1/0【一线端口】通告给邻居路由,说明1先也正常,即都正常。如果2线断线,端口就会down,route-map  redis_conn,也就不会将line2这条路有分布进bgp路由表,就不会宣告次要路由,也是有点类似交叉建邻居的方法,下面同理)  
  11. neighbor 12.1.2.2 remote-as 2  
  12. neighbor 12.1.2.2 update-source Serial1/1  
  13. neighbor 12.1.2.2 advertise-map dist_out2 exist-map line1  
  14. no auto-summary  
  15. !  
  16.   
  17. ip prefix-list dist_out2 seq 5 permit 192.168.2.0/24  
  18. !  
  19. ip prefix-list line1 seq 5 permit 12.1.1.0/30(外线一路由)  
  20. !           
  21. ip prefix-list line2 seq 5 permit 12.1.2.0/30(外线二路由)  
  22. !  
  23.   
  24. route-map redis_conn permit 10  
  25. match interface Serial1/0 Serial1/1  
  26.   
  27. route-map dist_out2 permit 10  
  28. match ip address prefix-list dist_out2  
  29. !  
  30.   
  31. route-map line2 permit 10  
  32. match ip address prefix-list line2  
  33. !  
  34. route-map line1 permit 10  
  35. match ip address prefix-list line1  
  36. !  
  37.   
  38. ISP(R2)  Config:     (ISP的配置很简单,基本什么都不做,实际来说,用户有什么需求,最好做在CE上面,PE上在能满足的要求的情况下,尽量精简配置,节约资源)  
  39. router bgp 2  
  40. no synchronization  
  41. bgp log-neighbor-changes  
  42. neighbor 12.1.1.1 remote-as 1  
  43. neighbor 12.1.1.1 update-source Serial1/0  
  44. neighbor 12.1.2.1 remote-as 1  
  45. neighbor 12.1.2.1 update-source Serial1/1  
  46. no auto-summar  
标签:

给我留言