客户需要将一部分服务器放到AWS云上,根据客户需求,让我们出一个方案。
客户内网与AWS通过BGP互联,最终要实现内网地址互通,并且来往路径一致,同时进行负载分担。于是,自己通过华为模拟器搭建实验环境,完成实验测试。

1.基础环境搭建:
R1 R2 R3 ibgp R2 R4 ,R3 R5起EBGP。 R4 R5 R6 起ibgp。R1,R2,R3 为我公司内网,在边界R1上进行路由宣告。最终要实现 访问6.6.6.6 走R1-R2-R4-R6 访问66.66.66.66 走R1,R3,R5,R6。2条链路互为备份。其中接口配置已在图中标明。
#R1bgp配置信息
<R1>display current-configuration configuration bgp 
bgp 100
 peer 12.1.1.2 as-number 100          建立ibgp邻居
 peer 13.1.1.3 as-number 100          建立ibgp邻居
 #
 ipv4-family unicast
  undo synchronization
  network 0.0.0.0 
  network 1.1.1.1 255.255.255.255         将网络宣告到bgp中   
  network 11.11.11.11 255.255.255.255     将网络宣告到bgp中
  peer 12.1.1.2 enable
  peer 13.1.1.3 enable
#R2bgp配置信息
<R2>display current-configuration configuration bgp 
[V200R003C00]
#
bgp 100
 peer 12.1.1.1 as-number 100     建立ibgp邻居
 peer 23.1.1.3 as-number 100 
 peer 24.1.1.4 as-number 200      建立ebgp邻居
 #
 ipv4-family unicast
  undo synchronization
  network 0.0.0.0 
  network 1.1.1.1 255.255.255.255 
  network 11.11.11.11 255.255.255.255 
  peer 12.1.1.1 enable
  peer 12.1.1.1 next-hop-local 
  peer 23.1.1.3 enable
  peer 24.1.1.4 enable
  peer 24.1.1.4 route-policy PrefVal import
#
#R3bgp配置信息
<R3>display current-configuration configuration bgp 
[V200R003C00]
#
bgp 100
 peer 13.1.1.1 as-number 100     建立ibgp邻居
 peer 23.1.1.2 as-number 100     建立ibgp邻居
 peer 35.1.1.5 as-number 200     建立ebgp邻居
 #
 ipv4-family unicast
  undo synchronization
  peer 13.1.1.1 enable
  peer 13.1.1.1 next-hop-local 
  peer 23.1.1.2 enable
  peer 35.1.1.5 enable
  peer 35.1.1.5 route-policy PrefVal import      
#2.BGP控制路由走向
我公司通过BGP的本地优先级属性,在R2使用route-policy匹配6.6.6.6,R2对6.6.6.6 设置本地优先级,让6.6.6.6 走R2-R4 链路。
<R2>display current-configuration configuration acl-basic 
[V200R003C00]
#
acl number 2001  
 rule 5 permit source 6.6.6.6 0
<R2>display current-configuration configuration route-policy 
[V200R003C00]
#
route-policy PrefVal permit node 10 
 if-match acl 2001 
 apply local-preference 200 
#
route-policy PrefVal permit node 20
bgp 100
  peer 24.1.1.4 route-policy PrefVal import在R3使用route-policy匹配66.66.66.66,R2对66.66.66.66 设置本地优先级,让66.66.66.66 走R3-R5链路。
<R3>display current-configuration configuration acl-basic 
[V200R003C00]
#
acl number 2001  
 rule 5 permit source 66.66.66.66 0   
#
<R3>display current-configuration configuration route-policy  
[V200R003C00]
#
route-policy PrefVal permit node 10 
 if-match acl 2001 
 apply local-preference 200 
#
route-policy PrefVal permit node 20
bgp 100
  peer 35.1.1.5 route-policy PrefVal import从R1上查看路由表可以看到6.6.6.6 走12.1.1.2,66.66.66.66 走13.1.1.3。并有备份路由进行备份。

查看tracert的路径。验证不管任何源去往6.6.6.6和66.66.66.66都是设定好的路线。

3.测试路由备份
将R2与R4,BGP互联的链路down掉之后,可以查看到R1上去往6.6.6.6 和66.66.66.66 的路由下一跳都发生了变化。都走13.1.1.3了。实现了路由在负载分担的基础上进行备份。


此时的下一跳全都走到了13.1.1.3(R3)。

在路由器里的切换是秒级的切换。具体切换时间还要用真实设备进行测试。
测试恢复链路:对R2的bgp链路进行恢复。链路恢复后,待到BGP邻居建立起来。去往6.6.6.6的路由也是秒级切换到了原来的路径。


1.1.1.1和11.11.11.11访问6.6.6.6 走R1-R2-R4-R6 访问66.66.66.66 走R1,R3,R5,R6。同时要实现路由原路返回
此时本段已经实现了路由分担,R4,R5,R6代表AWS侧,也一并进行测试。
4.iBGP的负载均衡
通过ibgp的负载均衡,实现去往1.1.1.1和11.11.11.11的路径是有备份链路的。
<R4>display current-configuration configuration bgp 
[V200R003C00]
#
bgp 200
 peer 24.1.1.2 as-number 100   建立ebgp
 peer 45.1.1.5 as-number 200   建立ibgp
 peer 46.1.1.6 as-number 200 
 #
 ipv4-family unicast
  undo synchronization
  peer 24.1.1.2 enable
  peer 45.1.1.5 enable
  peer 46.1.1.6 enable
  peer 46.1.1.6 next-hop-local 
#
<R5>display current-configuration configuration bgp 
[V200R003C00]
#
bgp 200
 peer 35.1.1.3 as-number 100   建立ebgp
 peer 45.1.1.4 as-number 200   建立ibgp
 peer 56.1.1.6 as-number 200 
 #
 ipv4-family unicast
  undo synchronization
  network 0.0.0.0 
  peer 35.1.1.3 enable
  peer 45.1.1.4 enable
  peer 56.1.1.6 enable
  peer 56.1.1.6 next-hop-local
<R6>display current-configuration configuration bgp 
[V200R003C00]
#
bgp 200
 peer 46.1.1.4 as-number 200      建立ibgp
 peer 56.1.1.5 as-number 200      建立ibgp
 #
 ipv4-family unicast
  undo synchronization
  network 6.6.6.6 255.255.255.255           宣告路由
  network 66.66.66.66 255.255.255.255       宣告路由
  maximum load-balancing ibgp 2           需要开启ibgp的负载均衡
  peer 46.1.1.4 enable
  peer 56.1.1.5 enable
#此时可以看到bgp的路由是负载均衡的。

5.基于源的策略路由
我们可以通过策略路由,做基于源地址的策略路由,此时就实现了路由1.1.1.1 和 11.11.11.11 访问的66.66.66.66 和6.6.6.6 来往路径都是一致的。
#R6配置acl,抓出2个要做策略的路由信息
R6]display current-configuration configuration acl-basic 
[V200R003C00]
#
acl number 2001  
 rule 5 permit source 6.6.6.6 0 
acl number 2002  
 rule 5 permit source 66.66.66.66 0 
#
#匹配不同的下一跳。
[R6]display current-configuration configuration policy-based-route 
[V200R003C00]
#
policy-based-route celue permit node 10
 if-match acl 2001
 apply output-interface GigabitEthernet0/0/0  
policy-based-route celue permit node 20
 if-match acl 2002
 apply output-interface GigabitEthernet0/0/1  
policy-based-route celue permit node 30
#
#应用生效策略路由。
ip local policy-based-route celue验证:
[R6]tracert -a 6.6.6.6 1.1.1.1
 traceroute to  1.1.1.1(1.1.1.1), max hops: 30 ,packet length: 40,press CTRL_C to break 
 1 46.1.1.4 30 ms  20 ms  10 ms 
 2 24.1.1.2 30 ms  30 ms  30 ms 
 3 12.1.1.1 60 ms  20 ms  20 ms 
[R6]tracert -a 6.6.6.6 11.11.11.11
 traceroute to  11.11.11.11(11.11.11.11), max hops: 30 ,packet length: 40,press CTRL_C to break 
 1 46.1.1.4 30 ms  20 ms  10 ms 
 2 24.1.1.2 20 ms  20 ms  20 ms 
 3 12.1.1.1 30 ms  10 ms  20 ms 
[R6]tracert -a 66.66.66.66 11.11.11.11
 traceroute to  11.11.11.11(11.11.11.11), max hops: 30 ,packet length: 40,press CTRL_C to break 
 1 56.1.1.5 30 ms  20 ms  30 ms 
 2 35.1.1.3 20 ms  30 ms  20 ms 
 3 13.1.1.1 20 ms  30 ms  40 ms
[R6]tracert -a 66.66.66.66 1.1.1.1    
 traceroute to  1.1.1.1(1.1.1.1), max hops: 30 ,packet length: 40,press CTRL_C to break 
 1 56.1.1.5 30 ms  20 ms  20 ms 
 2 35.1.1.3 30 ms  30 ms  20 ms 
 3 13.1.1.1 30 ms  30 ms  30 ms
保证6.6.6.6  走R1-R2-R4-R6   
66.66.66.66 走R1,R3,R5,R6。
2条链路互为备份。









