BGP的路由黑洞
1>图解BGP路由黑洞
2>路由黑洞解决方案
我们在配置BGP时最容易遇到的就是路由黑洞问题,简单的说, 它会默默的将数据包丢弃,使所有数据包有去无回。 对BGP来说由于存在IBGP水平分割规则,从一个IBGP邻居学到的路由条目不会传递给下一个IBGP邻居,这是一种AS内的防环机制,所以在BGP的设计上有些设备就不会运行BGP。BGP可以非直连建邻,所以路由传递是没有问题的,但是数据包的路由却是有问题的。通常我们可以看到的现像是IBGP邻居关系可以正常建立,也就是说控制平面看起来是正常的,但是数据平面确不可达。
1.图解BGP路由黑洞问题
在图中:
- R1-R2-R3之间起OSPF路由协议,且将环回地址宣告进入OSPF(环回地址命名,例:R1->loopback0 1.1.1.1)
- R1使用环回地址loopback0与R3建立IBGP邻居关系,同时R3也一样
- R1上将 loopback1(10.1.1.1) 宣告进入BGP,R3将loopback1(10.3.3.3)宣告进入BGP
2.解决方法
2.1 联盟【Confederations】
联盟(Confederations)是一组将大的自治系统分成子自治系统的一种方法,主要用于解决IBGP水平分割问题,通常与RR反射器联用,为了更好的控制IBGP对等关系
- 每一个联盟分配一个联盟ID,对于外端而言此联盟ID代表的是整个联盟的AS号,联盟其实质是对自治系统的再次细分
- AS_PATH中加入AS_CONFED_SEQUENCE和AS_CONFED_SET用法和AS_SEQUENCE和AS_SET一致
- 联盟环境下,所有路由器必须支持联盟
- 用预留的AS(64512~65535) 作为联盟中的AS编号是一种通用做法
- 选路优先级,普通EBGP>联盟EBGP>IBGP
- 联盟内部可以不修改next-hops、MED值,直接传递给其他AS成员,且可传递本地优先级Local_Pref
R1配置
R1(config)#no router bgp 100
**配置联盟**
R1(config)#router bgp 64513
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 2.2.2.2 remote-as 64513
R1(config-router)#neighbor 2.2.2.2 update-source loopback 0
R1(config-router)#neighbor 2.2.2.2 next-hop-self
R1(config-router)#network 10.1.1.1 mask 255.255.255.255
**在联盟内声明大AS号**
R1(config-router)#bgp confederation identifier 100
R1(config-router)#exit
R2配置
R2(config)#no router bgp 100
**配置联盟**
R2(config)#router bgp 64513
R2(config-router)#bgp router-id 2.2.2.2
**R1-R2联盟内IBGP邻居关系**
R2(config-router)#neighbor 1.1.1.1 remote-as 64513
R2(config-router)#neighbor 1.1.1.1 update-source loopback 0
R2(config-router)#neighbor 1.1.1.1 next-hop-self
**R2-R3 EBGP邻居关系**
R2(config-router)#neighbor 3.3.3.3 remote-as 100
R2(config-router)#neighbor 3.3.3.3 update-source loopback 0
R2(config-router)#neighbor 3.3.3.3 ebgp-multihop
**在联盟内声明大AS号**
R2(config-router)#bgp confederation identifier 100
R2(config-router)#bgp confederation peers 100
R3配置
R3(config)#router bgp 100
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 2.2.2.2 remote-as 64513
R3(config-router)#neighbor 2.2.2.2 update-source loopback 0
R3(config-router)#neighbor 2.2.2.2 ebgp-multihop
R3(config-router)#bgp confederation identifier 100
R3(config-router)#bgp confederation peers 64513
R3(config-router)#network 10.3.3.3 mask 255.255.255.255
R3(config-router)#end
2.2 路由反射器【Route Reflector】
IBGP的路由传递原则可以认为只传递一跳(IBGP的水平分割),在实际的网络中,设备非常多,网络连接非常负载,不太可能每个AS内的设备都有邻居关系,但是路由又必须传递下去,为了解决这一麻烦,产生了反射器技术,大量减少配置,减少邻居路由条目,减轻设备CPU负担,在实际网络环境中被大量使用,因为反射器配置非常简单。
RR反射器传递原则:
- RR收到的EBGP路由,会将其发送给所有EBGP邻居和IBGP邻居,包含反射器群成员及非成员
- RR收到RRC(客户端)的路由,会将其发送给所有EBGP邻居,所有的RRC和Non-RRC(非客户端)
- RR收到一条Non-RRC(非客户端)路由,会将其发送给所有的EBGP邻居及RRC(客户端),不传递给其他Non-RRC
R1配置
R1(config)#router bgp 100
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 2.2.2.2 remote-as 100
R1(config-router)#neighbor 2.2.2.2 update-source loopback 0
R1(config-router)#neighbor 2.2.2.2 next-hop-self
R1(config-router)#network 10.1.1.1 mask 255.255.255.255
R1(config-router)#exit
R2配置
R2(config)#router bgp 100
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 1.1.1.1 remote-as 100
R2(config-router)#neighbor 1.1.1.1 update-source loopback 0
R2(config-router)#neighbor 1.1.1.1 next-hop-self
R2(config-router)#neighbor 3.3.3.3 remote-as 100
R2(config-router)#neighbor 3.3.3.3 update-source loopback 0
R2(config-router)#neighbor 3.3.3.3 next-hop-self
**定义反射器,本地为RR**
R2(config-router)#neighbor 1.1.1.1 route-reflector-client
R2(config-router)#neighbor 3.3.3.3 route-reflector-client
R2(config-router)#exit
R3配置
R3(config)#router bgp 100
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 2.2.2.2 remote-as 100
R3(config-router)#neighbor 2.2.2.2 update-source loopback 0
R3(config-router)#neighbor 2.2.2.2 next-hop-self
R3(config-router)#network 10.3.3.3 mask 255.255.255.255
R3(config-router)#exit
2.3 BGP导入IGP【实验环境】
这种方法仅适用于实验环境,在实验环境中BGP路由条目少,IGP可以承担起对于BGP路由的计算,但是在真实环境中,BGP的路由往往是一个AS,甚至于不同AS的路由条目,路由非常之多,IGP协议不足以承担起如此大路由计算
原理: 利用底层IGP传递BGP的路由条目
R1配置
R1(config)#router bgp 100
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 2.2.2.2 remote-as 100
R1(config-router)#neighbor 2.2.2.2 update-source loopback 0
R1(config-router)#neighbor 2.2.2.2 next-hop-self
R1(config-router)#network 10.1.1.1 mask 255.255.255.255
R1(config-router)#exit
**BGP导入IGP**
R1(config)#router ospf 1
R1(config-router)#redistribute bgp 100 subnets
R2配置
R2(config)#router bgp 100
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 1.1.1.1 remote-as 100
R2(config-router)#neighbor 1.1.1.1 update-source loopback 0
R2(config-router)#neighbor 1.1.1.1 next-hop-self
R2(config-router)#neighbor 3.3.3.3 remote-as 100
R2(config-router)#neighbor 3.3.3.3 update-source loopback 0
R2(config-router)#neighbor 3.3.3.3 next-hop-self
R2(config-router)#exit
R3配置
R3(config)#router bgp 100
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 2.2.2.2 remote-as 100
R3(config-router)#neighbor 2.2.2.2 update-source loopback 0
R3(config-router)#neighbor 2.2.2.2 next-hop-self
R3(config-router)#network 10.3.3.3 mask 255.255.255.255
R3(config-router)#exit
**BGP导入IGP**
R3(config)#router ospf 1
R3(config-router)#redistribute bgp 100 subnets