BGP Confederation(BGP联邦)

BGP Confederation(BGP联邦)

为了解决由于从iBGP邻居收到的路由不能转发给其它iBGP邻居的限制问题,除了可以使用在iBGP邻居之间创建全互联的邻居关系和使用BGPReflector之外,还可以使用BGP Confederation(BGP联邦)。

因为只有从iBGP邻居收到的路由才不能转发给其它iBGP邻居,而从eBGP邻居收到的路由可以转发给任何邻居,包括iBGP邻居,所以在拥有多个路由器的大型AS中,BGPConfederation采用在AS内部建立多个子AS的方法,从而将一个大的AS分割成多个小型AS,让AS内部拥有足够数量的eBGP邻居关系来解决路由限制问题。如下图

                                      

在上图中,当R3从iBGP邻居R1收到路由后,不能再转发给iBGP邻居R4,而R2从eBGP邻居R5收到R1的路由后,因为拥有自己的AS号码,最后将路由丢弃而不转发给R4,最终造成R4拥有不完整的路由表,同样R3也像R4一样不能拥有完整的路由表。

对于上述问题,可以创建全互联的BGP邻居关系,或者在R3和R4上配置BGP Reflector的方法来解决。除此之外,还可以使用在AS内部创建BGPConfederation的方法来解决,如下:

                                          

在上图环境中,通过BGP Confederation的方式在R1与R3之间创建子AS 64512,而在R2与R4之间创建子AS64513,这样一来,在R1将全部路由发给R3,以及R2将全部路由发给R4之后,

因为R3与R4是eBGP邻居的关系,所以R3与R4之间可以任意转发BGP路由信息,从而使双方都拥有完整的全网路由表。

在使用BGP Confederation在AS内部创建子AS时,建议使用私有AS号码,范围是64512-65534,所有BGPConfederation内部的子AS,对于外界都是不可见的,如上图中,R1与R2在AS 1中分别为AS 64512和AS 64513,但是对于R5来说,R1和R2都为AS1的,而AS 64512和AS 64513对于R5来说是透明的,外界并不知道AS内部是否创建了BGP Confederation,对于子AS的号码只在AS内部传递路由时才会添加到AS_Path中去,在出AS时,这些子AS号码是不会写入AS_Path的。

 

注:

★在路径属性中,联邦内部的子AS是不被AS_Path计算在内的。

★在选路规则中,比较eBGP与iBGP邻居类型时,AS内部的子AS之间是不作eBGP与iBGP邻居类型比较的。

配置BGP Confederation

                                     

说明:

上图中所有路由器都配有Loopback地址,地址分别为:

R1  Loopback0  1.1.1.1/32      Loopback 11  11.1.1.1/24

R2  Loopback0  2.2.2.2/32      Loopback 22  22.2.2.2/24

R3  Loopback0  3.3.3.3/32      Loopback 33  33.3.3.3/24

R4  Loopback0  4.4.4.4/32      Loopback 44  44.4.4.4/24

R5  Loopback0  5.5.5.5/32      Loopback 55 55.5.5.5/24

所有路由器之间运行OSPF,并将Loopback 0的地址发布到OSPF中,保证全网Loopback 0之间是可以通信的。

 

1.IGP保证全网Loopback 0互通

(1)配置OSPF

说明:此步略,请参见之前配置。

(2)测试全网Loopback 0连通性

r5#ping 1.1.1.1 source loopback 0

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is2 seconds:

Packet sent with a source address of 5.5.5.5

!!!!!

Success rate is 100 percent (5/5), round-tripmin/avg/max = 8/114/228 ms

r5#ping 2.2.2.2 source loopback 0

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is2 seconds:

Packet sent with a source address of 5.5.5.5

!!!!!

Success rate is 100 percent (5/5), round-tripmin/avg/max = 56/84/128 ms

r5#

r5#

r5#ping 3.3.3.3 source loopback 0

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is2 seconds:

Packet sent with a source address of 5.5.5.5

!!!!!

Success rate is 100 percent (5/5), round-tripmin/avg/max = 16/106/180 ms

r5#ping 4.4.4.4 source loopback 0

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is2 seconds:

Packet sent with a source address of 5.5.5.5

!!!!!

Success rate is 100 percent (5/5), round-tripmin/avg/max = 48/124/224 ms

r5#

说明:全网Loopback 0连通性连通性正常。

 

 

2.配置BGP Confederation

(1)在R5上配置BGP

r5(config)#router bgp 5

r5(config-router)#bgp router-id 5.5.5.5

r5(config-router)#neighbor 1.1.1.1 remote-as 1

r5(config-router)#neighbor 1.1.1.1 update-sourceloopback 0

r5(config-router)#neighbor 1.1.1.1 ebgp-multihop

r5(config-router)#neighbor 2.2.2.2 remote-as 1

r5(config-router)#neighbor 2.2.2.2 update-sourceloopback 0

r5(config-router)#neighbor 2.2.2.2 ebgp-multihop

r5(config-router)#network 55.5.5.0 mask 255.255.255.0

说明:R5的配置常规不变。

 

(2)在R1上配置BGP Confederation

r1(config)#router bgp 64512

r1(config-router)#bgp router-id 1.1.1.1

r1(config-router)#bgp confederation identifier 1

r1(config-router)#bgp confederation peers 64513

r1(config-router)#neighbor 5.5.5.5 remote-as 5

r1(config-router)#neighbor 5.5.5.5 update-sourceloopback 0

r1(config-router)#neighbor 5.5.5.5 ebgp-multihop

r1(config-router)#neighbor 2.2.2.2 remote-as 64513

r1(config-router)#neighbor 2.2.2.2 update-sourceloopback 0

r1(config-router)#neighbor 2.2.2.2 ebgp-multihop

r1(config-router)#neighbor 3.3.3.3 remote-as 64512

r1(config-router)#neighbor 3.3.3.3 update-sourceloopback 0

r1(config-router)#network 11.1.1.0 mask 255.255.255.0

说明:指定子AS为64512,而真正的AS为1,并指明与AS 64513同属一个AS,在联邦内部与R2为eBGP关系,与R3为iBGP关系。

 

(3)在R2上配置BGP Confederation

r2(config)#router bgp 64513

r2(config-router)#bgp router-id 2.2.2.2

r2(config-router)#bgp confederation identifier 1  

r2(config-router)#bgp confederation peers 64512

r2(config-router)#neighbor 5.5.5.5 remote-as 5

r2(config-router)#neighbor 5.5.5.5 update-sourceloopback 0

r2(config-router)#neighbor 5.5.5.5 ebgp-multihop

r2(config-router)#neighbor 1.1.1.1 remote-as 64512

r2(config-router)#neighbor 1.1.1.1 update-sourceloopback 0

r2(config-router)#neighbor 1.1.1.1 ebgp-multihop

r2(config-router)#neighbor 4.4.4.4 remote-as 64513

r2(config-router)#neighbor 4.4.4.4 update-sourceloopback 0

r2(config-router)#network 22.2.2.0 mask 255.255.255.0

 

说明:指定子AS为64513,而真正的AS为1,并指明与AS 64512同属一个AS,在联邦内部与R1为eBGP关系,与R4为iBGP关系。

(4)在R3上配置BGP Confederation

r3(config)#router bgp 64512

r3(config-router)#bgp router-id 3.3.3.3

r3(config-router)#bgp confederation identifier 1

r3(config-router)#bgp confederation peers 64513

r3(config-router)#neighbor 1.1.1.1 remote-as 64512

r3(config-router)#neighbor 1.1.1.1 update-sourceloopback 0

r3(config-router)#neighbor 4.4.4.4 remote-as 64513

r3(config-router)#neighbor 4.4.4.4 update-sourceloopback 0

r3(config-router)#neighbor 4.4.4.4 ebgp-multihop

r3(config-router)#network 33.3.3.0 mask 255.255.255.0

说明:指定子AS为64512,而真正的AS为1,并指明与AS 64513同属一个AS,在联邦内部与R4为eBGP关系,与R1为iBGP关系。

(5)在R4上配置BGP Confederation

r4(config)#router bgp 64513

r4(config-router)#bgp router-id 4.4.4.4

r4(config-router)#bgp confederation identifier 1

r4(config-router)#bgp confederation peers 64512

r4(config-router)#neighbor 2.2.2.2 remote-as 64513

r4(config-router)#neighbor 2.2.2.2 update-sourceloopback 0

r4(config-router)#neighbor 3.3.3.3 remote-as 64512

r4(config-router)#neighbor 3.3.3.3 update-sourceloopback 0

r4(config-router)#neighbor 3.3.3.3 ebgp-multihop

r4(config-router)#network 44.4.4.0 mask 255.255.255.0

说明:指定子AS为64513,而真正的AS为1,并指明与AS 64512同属一个AS,在联邦内部与R3为eBGP关系,与R1为iBGP关系。

 

3.查看BGP邻居关系

(1)查看R5的BGP邻居状况

r5#sh ip bgp summary

BGP router identifier 5.5.5.5, local AS number 5

BGP table version is 6, main routing table version 6

5 network entries using 645 bytes of memory

9 path entries using 468 bytes of memory

4/3 BGP path/bestpath attribute entries using 496bytes of memory

1 BGP AS-PATH entries using 24 bytes of memory

0 BGP route-map cache entries using 0 bytes of memory

0 BGP filter-list cache entries using 0 bytes ofmemory

BGP using 1633 total bytes of memory

BGP activity 5/0 prefixes, 9/0 paths, scan interval 60secs

 

Neighbor       V    AS MsgRcvd MsgSent   TblVer InQ OutQ Up/Down  State/PfxRcd

1.1.1.1        4     1      25     26        6    0   0 00:17:30        4

2.2.2.2        4     1      15     16        6    0   0 00:07:08        4

r5#

说明:R1与R2在联邦内部虽然为AS 64512和AS 64513,但对于R5来说,它们都为AS 1,子AS则透明不可见。

 

(2)查看R1的BGP邻居状况

r1#sh ip bgp summary

BGP router identifier 1.1.1.1, local AS number 64512

BGP table version is 6, main routing table version 6

5 network entries using 645 bytes of memory

6 path entries using 312 bytes of memory

6/4 BGP path/bestpath attribute entries using 744bytes of memory

3 BGP AS-PATH entries using 72 bytes of memory

0 BGP route-map cache entries using 0 bytes of memory

0 BGP filter-list cache entries using 0 bytes ofmemory

BGP using 1773 total bytes of memory

BGP activity 5/0 prefixes, 6/0 paths, scan interval 60secs

 

Neighbor       V    AS MsgRcvd MsgSent   TblVer InQ OutQ Up/Down  State/PfxRcd

2.2.2.2        4 64513      13      13       6    0    0 00:06:27        3

3.3.3.3        4 64512       8      11       6    0    0 00:03:14        1

5.5.5.5        4     5      26     25        6    0   0 00:17:51        1

r1#

说明:子AS在联邦内部AS之间可见。

 

注:其它BGP邻居关系类同,不再一一查看。

 

 

4.查看BGP路由情况

(1)查看R5的BGP路由情况

r5#sh ip bgp

BGP table version is 6, local router ID is 5.5.5.5

Status codes: s suppressed, d damped, h history, *valid, > best, i - internal,

              rRIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path

* 11.1.1.0/24      2.2.2.2                                0 1 i

*>                 1.1.1.1                  0             0 1 i

* 22.2.2.0/24      1.1.1.1                                0 1 i

*>                 2.2.2.2                  0             0 1 i

* 33.3.3.0/24      2.2.2.2                                0 1 i

*>                 1.1.1.1                               0 1 i

* 44.4.4.0/24      1.1.1.1                                0 1 i

*>                 2.2.2.2                               0 1 i

*> 55.5.5.0/24     0.0.0.0                  0         32768 i

r5#

说明:R5已经收到全部的路由,说明对方AS内部正常稳定运行。

(2)查看R1的BGP路由情况

r1#sh ip bgp

BGP table version is 6, local router ID is 1.1.1.1

Status codes: s suppressed, d damped, h history, *valid, > best, i - internal,

              rRIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24     0.0.0.0                  0         32768 i

*> 22.2.2.0/24     2.2.2.2                  0   100      0 (64513) i

*>i33.3.3.0/24     3.3.3.3                  0    100     0 i

*> 44.4.4.0/24     4.4.4.4                  0    100     0 (64513) i

* 55.5.5.0/24      5.5.5.5                  0    100     0 (64513) 5 i

*>                 5.5.5.5                  0             0 5 i

r1#

说明:R1也收到全部路由,说明BGP邻居正常运行,且路由收发和预期相同。需要注意,虽然在AS内部,R1与R2为eBGP邻居关系,但下一跳属性并没有作修改,所以需要手工修改。

(3)修改R2对R1的下一跳属性

r2(config)#router bgp 64513

r2(config-router)#neighbor 1.1.1.1 next-hop-self

 

(4)再次查看R1的BGP路由情况

r1#sh ip bgp

BGP table version is 7, local router ID is 1.1.1.1

Status codes: s suppressed, d damped, h history, *valid, > best, i - internal,

              rRIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24     0.0.0.0                  0         32768 i

*> 22.2.2.0/24     2.2.2.2                  0    100     0 (64513) i

*>i33.3.3.0/24     3.3.3.3                  0    100     0 i

* i44.4.4.0/24     4.4.4.4                  0    100     0 (64513) i

*>                 2.2.2.2                  0    100     0 (64513) i

* 55.5.5.0/24      2.2.2.2                  0    100     0 (64513) 5 i

*>                 5.5.5.5                  0             0 5 i

r1#

说明:R2对R1的下一跳属性成功修改。

 

 

(5)AS内部都将改变下一跳属性

 R1:

r1(config)#router bgp 64512

r1(config-router)#neighbor 2.2.2.2 next-hop-self

r1(config-router)#neighbor 3.3.3.3 next-hop-self

 

R3:

r3(config)#router bgp 64512

r3(config-router)#neighbor 1.1.1.1 next-hop-self

r3(config-router)#neighbor 4.4.4.4 next-hop-self

 

R4:

r4(config)#router bgp 64513

r4(config-router)#neighbor 2.2.2.2 next-hop-self

r4(config-router)#neighbor 3.3.3.3 next-hop-self

 

 

5.测试BGP联邦内部选路

(1)查看R1当前的BGP路由情况

r1#sh ip bgp

BGP table version is 7, local router ID is 1.1.1.1

Status codes: s suppressed, d damped, h history, *valid, > best, i - internal,

              rRIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24     0.0.0.0                  0         32768 i

*> 22.2.2.0/24     2.2.2.2                  0    100     0 (64513) i

*>i33.3.3.0/24     3.3.3.3                  0    100     0 i

*> 44.4.4.0/24     2.2.2.2                  0    100     0 (64513) i

* 55.5.5.0/24      2.2.2.2                  0    100     0 (64513) 5 i

*>                 5.5.5.5                  0             0 5 i

r1#

说明:R1到达R5的网段55.5.5.0/24从S0/0出去。

 

(2)在R1上改变去往55.5.5.0/24的路径

说明:因为在路径比较中,联邦内部AS_Path是不被计算在内的,所以要证明虽然R1去往55.5.5.0/24,从R2走的AS_Path要长于R5,但并不是因为R2的AS_Path比R5长,因为子AS不被计算,所以只要选路规则的属性中AS_Path后面一个属性的变更影响到选路后,就能证明子AS是被忽略的,所以在此选择修改AS_Path后面的属性,如MED。

r1(config)#access-list 55 permit 55.5.5.0

 

r1(config)#route-map med permit 10

r1(config-route-map)#match ip address 55

r1(config-route-map)#set metric 55

r1(config-route-map)#exit

r1(config)#route-map med permit 20

r1(config-route-map)#exit

 

r1(config)#router bgp 64512

r1(config-router)#neighbor 5.5.5.5 route-map med in

说明:将走R5的MED值设置为55,大于R2的MED值0。

(3)再次查看R1去往55.5.5.0/24的路径

r1#sh ip bgp               

BGP table version is 8, local router ID is 1.1.1.1

Status codes: s suppressed, d damped, h history, *valid, > best, i - internal,

              rRIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path

*> 11.1.1.0/24     0.0.0.0                  0         32768 i

*> 22.2.2.0/24     2.2.2.2                  0    100     0 (64513) i

*>i33.3.3.0/24     3.3.3.3                  0    100     0 i

*> 44.4.4.0/24     2.2.2.2                  0    100     0 (64513) i

*> 55.5.5.0/24     2.2.2.2                  0    100     0 (64513) 5 i

*                   5.5.5.5                 55             0 5 i

r1#

说明:R1去往55.5.5.0/24选择从R2走,虽然R1的AS_Path看起来比R5长,但因为联邦内部的子AS不被计算,所以最终因为R2的低MED值影响了选路,所以eBGP邻居优于iBGP邻居的规则在BGP联邦内部是被忽略的。

 

(4)查看R3的BGP路径

r3#sh ip bgp

BGP table version is 12, local router ID is 3.3.3.3

Status codes: s suppressed, d damped, h history, *valid, > best, i - internal,

              rRIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric LocPrf Weight Path

*>i11.1.1.0/24     1.1.1.1                  0    100     0 i

* 22.2.2.0/24      4.4.4.4                  0    100     0 (64513) i

*>i                1.1.1.1                  0    100     0 (64513) i

*> 33.3.3.0/24     0.0.0.0                  0         32768 i

* 44.4.4.0/24      4.4.4.4                  0    100     0 (64513) i

*>i                1.1.1.1                  0    100     0 (64513) i

* 55.5.5.0/24      4.4.4.4                  0    100     0 (64513) 5 i

*>i                1.1.1.1                  0    100     0 (64513) 5 i

r3#

说明:可以看见,R3去往55.5.5.0/24,下一跳选择了iBGP邻居R1而没有选择eBGP邻居R4,所以再一次证实了eBGP邻居优于iBGP邻居的选路规则在BGP联邦内部是被忽略的。