BGP路由黑洞

BGP路由黑洞
IP地址如图所示;
AR1和AR2配置EBGP,AR4和AR5也配置EBGP,AR2和AR4配置IBGP;
根据BGP选路原则4:(一条从IBGP学习到的路由发给BGP邻居以前,经过IGP必须知道该路由,即IGP与BGP同步)。在华为路由器上,默认是将BGP于IGP的同步检查关闭的,缘由是为了实现IBGP路由的正常通告。但关闭同步会出现“路由黑洞”。所以有两种解决方案:1.将BGP路由引入IGP,2.IBGP路由器必须全互联。
BGP配置运维

AR1配置:
bgp 10
 router-id 10.0.1.1
 peer 10.0.12.2 as-number 20 
 ipv4-family unicast
  undo synchronization
  network 10.0.1.1 255.255.255.255 
  network 10.0.12.0 255.255.255.0 
  peer 10.0.12.2 enable

配置next-hop-local缘由是:IBGP从EBGP学习到路由下一跳不变,会致使下一跳不可达,因此IBGP配置local,告知下一跳是本身。ide

AR2:
bgp 20
router-id 10.0.2.2
 peer 10.0.4.4 as-number 20 
 peer 10.0.4.4 connect-interface LoopBack0
 peer 10.0.12.1 as-number 10 
 ipv4-family unicast
  undo synchronization
  peer 10.0.4.4 enable
  peer 10.0.4.4 next-hop-local 
  peer 10.0.12.1 enable
AR4:
bgp 20
 router-id 10.0.4.4
 peer 10.0.2.2 as-number 20 
 peer 10.0.2.2 connect-interface LoopBack0
 peer 10.0.45.5 as-number 30 
 ipv4-family unicast
  undo synchronization
  peer 10.0.2.2 enable
  peer 10.0.2.2 next-hop-local 
  peer 10.0.45.5 enable
AR5:
bgp 30
 router-id 10.0.5.5
 peer 10.0.45.4 as-number 20 
 ipv4-family unicast
  undo synchronization
  network 10.0.5.5 255.255.255.255 
  network 10.0.45.0 255.255.255.0 
  peer 10.0.45.4 enable

AR2,AR3,AR4配置OSPF 1oop

ospf 1 router-id 10.0.0.2 
 area 0.0.0.0 
  network 10.0.2.2 0.0.0.0 
  network 10.0.23.0 0.0.0.255 

ospf 1 router-id 10.0.0.3
 area 0.0.0.0 
  network 10.0.3.3 0.0.0.0 
  network 10.0.23.0 0.0.0.255 
  network 10.0.34.0 0.0.0.255

ospf 1 router-id 10.0.0.4
 area 0.0.0.0 
  network 10.0.4.4 0.0.0.0 
  network 10.0.34.0 0.0.0.255
根据BGP第四条选路原则,当IBGP学到的路由传递给BGP邻居以前经过IGP必须知道该路由,也就是说,AR2学习到的AR1的的路由传递给AR4时,改路由通过AR3,AR3必须知道AR1的路由;同理也必须知道AR5的路由,能够经过IBGP全互联和OSPF 引入BGP解决此问题;
办法1 ospf引入bgp(若是是公网bgp,不建议这么搞,除非你路由器和运维能力很牛逼):

AR2和AR4分别:
bgp 20
import-route bgp学习

 
 

办法2 IBGP全互联:code

AR2:
bgp 20
 router-id 10.0.2.2
 peer 10.0.3.3 as-number 20 
 peer 10.0.3.3 connect-interface LoopBack0
 peer 10.0.4.4 as-number 20 
 peer 10.0.4.4 connect-interface LoopBack0
 ipv4-family unicast
  undo synchronization
  peer 10.0.3.3 enable
  peer 10.0.3.3 next-hop-local 
  peer 10.0.4.4 enable
  peer 10.0.4.4 next-hop-local 
AR3:
bgp 20
 router-id 10.0.3.3
 peer 10.0.2.2 as-number 20 
 peer 10.0.2.2 connect-interface LoopBack0
 peer 10.0.4.4 as-number 20 
 peer 10.0.4.4 connect-interface LoopBack0
 ipv4-family unicast
  undo synchronization
  peer 10.0.2.2 enable
  peer 10.0.4.4 enable
  AR4:bgp 20
 router-id 10.0.4.4
 peer 10.0.2.2 as-number 20 
 peer 10.0.2.2 connect-interface LoopBack0
 peer 10.0.3.3 as-number 20 
 peer 10.0.3.3 connect-interface LoopBack0
 ipv4-family unicast
  undo synchronization
  peer 10.0.2.2 enable
  peer 10.0.2.2 next-hop-local 
  peer 10.0.3.3 enable
  peer 10.0.3.3 next-hop-local