IPA-taskpacket006BGP社团属性

   实验六:BGP的社团属性

实验目标

1.熟练BGP的基本配置

2.掌握BGP社团属性的原理

实验TOP

wKioL1NPj9rjW9DAAAG3ov9sdrM819.jpg

物理拓扑

wKiom1NPkCSRjm3AAAHDJFdvE1k921.jpg

逻辑拓扑




基本配置


R1的配置:


!

hostname R1

!

interface Loopback0

ip address 1.1.1.1255.255.255.0

!

interface Serial1/0

ip address 12.1.1.1255.255.255.0

!

interface Serial2/0

ip address 13.1.1.1255.255.255.0

!

router ospf 10

network 12.1.1.0 0.0.0.255area 0

network 13.1.1.0 0.0.0.255area 0

!

router bgp 10

no synchronization

bgp router-id 1.1.1.1

network 1.1.1.0 mask255.255.255.0

neighbor 12.1.1.2 remote-as10

neighbor 13.1.1.3 remote-as50

no auto-summary

!

line con 0

logging synchronous

!


R2的配置:


!

hostname R2

!

interface Loopback0

ip address 2.2.2.2255.255.255.0

!

interface Serial1/0

ip address 24.1.1.2255.255.255.0

!

interface Serial2/0

ip address 12.1.1.2255.255.255.0

!

router ospf 10

network 12.1.1.0 0.0.0.255area 0

network 24.1.1.0 0.0.0.255area 0

!

router bgp 10

no synchronization

bgp router-id 2.2.2.2

network 2.2.2.0 mask255.255.255.0

neighbor 12.1.1.1 remote-as10

neighbor 24.1.1.4 remote-as30

no auto-summary

!

!

line con 0

logging synchronous

!


R3的配置:


!

hostname R3

!

!

interface Loopback0

ip address 3.3.3.3255.255.255.0

!

!

interface Serial1/0

ip address 13.1.1.3255.255.255.0

!

interface Serial2/0

ip address 35.1.1.3255.255.255.0

!

router ospf 10

network 13.1.1.0 0.0.0.255area 0

network 35.1.1.0 0.0.0.255area 0

!

router bgp 50

no synchronization

bgp router-id 3.3.3.3

network 3.3.3.0 mask255.255.255.0

neighbor 13.1.1.1 remote-as10

neighbor 35.1.1.5 remote-as50

no auto-summary

!

!

line con 0

logging synchronous

!


R4配置:


!

hostname R4

!

!

interface Loopback0

ip address 4.4.4.4255.255.255.0

!

interface Serial1/0

ip address 45.1.1.4255.255.255.0

!

interface Serial2/0

ip address 24.1.1.4255.255.255.0

!

router ospf 10

network 24.1.1.0 0.0.0.255area 0

network 45.1.1.0 0.0.0.255area 0

!

router bgp 30

no synchronization

bgp router-id 4.4.4.4

network 4.4.4.0 mask255.255.255.0

neighbor 24.1.1.2 remote-as10

neighbor 45.1.1.5 remote-as50

no auto-summary

!

line con 0

logging synchronous

!


R5配置:


!

hostname R5

!

interface Loopback0

ip address 5.5.5.5255.255.255.0

!

!

interface Serial1/0

ip address 35.1.1.5255.255.255.0

!

interface Serial2/0

ip address 45.1.1.5255.255.255.0

!

router ospf 10

network 35.1.1.0 0.0.0.255area 0

network 45.1.1.0 0.0.0.255 area0

!

router bgp 50

no synchronization

bgp router-id 5.5.5.5

network 5.5.5.0 mask255.255.255.0

neighbor 35.1.1.3 remote-as50

neighbor 45.1.1.4 remote-as30

no auto-summary

!

!

line con 0

logging synchronous

!



备注:路由器默认情况下接口都是关闭着的,我们在做实验的时候把接口都开启



测试1:社团属性NO-EXPORTTOP如上所示)


当一台BGP路由器收到来自对等体通告的携带no-export社团属性的路由条目时,该BGP路由器不会把学习到的对应的路由条目通告给其他eBGP对等体(如果收到该社团属性的路由器处在一个联邦内,那么携带该属性的路由会在该联邦内传递,即会在联邦子AS之间传递)。


调试:


我们知道,正常情况下,BGP的路由传递遵守其自身的路由传递原则,关于路由传递原则,这里不做介绍。


首先,我们配置R1,让R1在通告1.1.1.0/24R3时,加上no-export属性


R1(config)#access-list 1 permit 1.1.1.0

R1(config)#route-map r1-r3

R1(config-route-map)#match ip address 1

R1(config-route-map)#set communityno-export

R1(config-route-map)#exit

R1(config)#route-map r1-r3 permit 20

R1(config-route-map)#router bgp 10

R1(config-router)#neighbor 13.1.1.3route-map r1-r3 out

R1(config-route-map)#exit

R1#clear ip bgp * soft



查看R4BGP


R4#show ip bgp

BGP table version is 11, local router ID is4.4.4.4

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

             r RIB-failure, S Stale

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


 Network          Next Hop            Metric LocPrf Weight Path

*  1.1.1.0/24       45.1.1.5                               0 50 10 i

*>                  24.1.1.2                               0 10 i

* 2.2.2.0/24       45.1.1.5                               0 50 10 i

*>                  24.1.1.2                 0             0 10 i

* 3.3.3.0/24       24.1.1.2                               0 10 50 i

*>                  45.1.1.5                               0 50 i

*> 4.4.4.0/24       0.0.0.0                  0         32768 i

* 5.5.5.0/24       24.1.1.2                               0 10 50 i

*>                  45.1.1.5                 0             0 50 i

//我们发现此时,R4学习到的1.1.1.0/24网段,结果与我们分析的不一致,原因在下文阐述


通过上面的测试,我们知道R5仍然将1.1.1.0/24通告给了eBGP对等体R4,因为社团属性的传递要求必须在对等体之间指定send-community,配置如下:


R1(config)#router bgp 10

R1(config-router)#neighbor 13.1.1.3 send-community

R1#clear ip bgp * out



接下来我们查看R3是否已经收到带社团属性的1.1.1.0/24网段的条目:


R3#show ip bgp community

BGP table version is 20, local router ID is3.3.3.3

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

             r RIB-failure, S Stale

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


 Network          Next Hop            Metric LocPrf Weight Path

*> 1.1.1.0/24       13.1.1.1                 0             0 10 i


R3#show ip bgp 1.1.1.0

BGP routing table entry for 1.1.1.0/24,version 19

Paths: (1 available, best #1, tableDefault-IP-Routing-Table, not advertised to EBGP peer)

Advertised to non peer-group peers:

35.1.1.5

 10

  13.1.1.1 from 13.1.1.1 (1.1.1.1)

    Origin IGP, metric 0, localpref 100, valid, external, best

Community:no-export


//我们发现,R3收到了来自R1发送过来的携带社团属性no-export1.1.1.0/24网段


同样,此时R3也不会自动把社团属性传递给R5,因此还需要在R3配置:


R3(config)#router bgp 50

R3(config-router)#neighbor 35.1.1.5 send-community

R3(config-router)#end

R3#clear ip bgp * out



确认R5已经收到对应的属性:


R5#show ip bgp community

BGP table version is 16, local router ID is5.5.5.5

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

             r RIB-failure, S Stale

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


 Network          Next Hop            Metric LocPrf Weight Path

*>i1.1.1.0/24       13.1.1.1                 0    100     0 10 i


//上面显示R5已经收到带社团属性的1.1.1.0/24条目


R5#show ip bgp neighbors 45.1.1.4advertised-routes

BGP table version is 16, local router ID is5.5.5.5

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

             r RIB-failure, S Stale

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


 Network          Next Hop            Metric LocPrf Weight Path

*>i2.2.2.0/24       13.1.1.1                 0    100     0 10 i

*>i3.3.3.0/24       35.1.1.3                 0    100     0 i

*> 5.5.5.0/24       0.0.0.0                  0         32768 i


//此时,R5R4发送的BGP更新条目中已不包含1.1.1.0/24网段


现在我们查看R4BGP表的变化:


R4#show ip bgp

BGP table version is 13, local router ID is4.4.4.4

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

             r RIB-failure, S Stale

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


 Network          Next Hop            Metric LocPrf Weight Path

*> 1.1.1.0/24      24.1.1.2                              0 10 i

* 2.2.2.0/24       45.1.1.5                               0 50 10 i

*>                  24.1.1.2                 0             0 10 i

* 3.3.3.0/24       24.1.1.2                               0 10 50 i

*>                  45.1.1.5                               0 50 i

*> 4.4.4.0/24       0.0.0.0                  0         32768 i

* 5.5.5.0/24       24.1.1.2                               0 10 50 i

*>                  45.1.1.5                 0             0 50 i


此时,R4学习1.1.1.0/24网段在BGP表中只有一个下一跳,即为R2;说明R5并没有把自己收到的携带no-export社团属性的路由传递给eBGP对等体R4



测试2NO-ADVERTISETOP如上所示)

当一台BGP路由器收到来自对等体通告的携带no-advertise社团属性的路由条目时,该BGP路由器不会把学习到的对应的路由条目通告给其他任何对等体(包含eBGP对等体和iBGP对等体,如果收到该社团属性的路由器处在一个联邦内,那么携带该属性的路由也不会在该联邦内传递,即不会在联邦子AS之间传递)。



调试:


R1增加一条11.11.11.11/24BGP条目,并且在发送BGP更新时携带no-advertise社团属性,我们来观察R3是否会将从R1学习到的该条目传递的其他bgp对等体。


R1(config)#int loopback 11

R1(config-if)#ip address 11.11.11.11255.255.255.0

R1(config-if)#exit

R1(config)#access-list 11 permit 11.11.11.0


这里注意:route-map名称可以不变、序号和原来相比保持连续,上一个route-map序号20permit any,因此设置属性的条目要在此之前,否之因执行顺序的问题,R1会直接不携带属性通告出去,配置如下:


R1(config)#route-map r1-r3 permit 15

R1(config-route-map)#match ip address 11

R1(config-route-map)#set community no-advertise

R1(config-route-map)#exit

R1(config)#router bgp 10

R1(config-router)#network 11.11.11.0 mask255.255.255.0

R1(config-router)#end

R1#clear ip bgp * soft



验证R3,可见R3已经收到携带该属性的条目:


R3#show ip bgp community

BGP table version is 28, local router ID is3.3.3.3

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

             r RIB-failure, S Stale

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


 Network          Next Hop            Metric LocPrf Weight Path

*> 1.1.1.0/24       13.1.1.1                 0             0 10 i

*> 11.11.11.0/24    13.1.1.1                 0             0 10 i



再查看R3R5的通告:


R3#show ip bgp neighbors 35.1.1.5 advertised-routes

BGP table version is 28, local router ID is3.3.3.3

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

             r RIB-failure, S Stale

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


 Network          Next Hop            Metric LocPrf Weight Path

*> 1.1.1.0/24       13.1.1.1                 0             0 10 i

*> 2.2.2.0/24       13.1.1.1                               0 10 i

*> 3.3.3.0/24       0.0.0.0                  0         32768 i


//不会包含11.11.11.0/24,因为获得带no-advertise的路由条目时,便不会再往任何对等体通告了






测试3local-AS(备注:由于测试3独立于测试12,所以显示的测试结果与连续做下来后所显示的结果可能不同)(TOP如下所示)




spacer.gif

逻辑拓扑


当一台BGP路由器收到来自对等体通告的携带local-as社团属性的路由条目时,该BGP路由器不会把学习到的对应的路由条目通告给其他eBGP对等体(如果收到该社团属性的路由器处在一个联邦内,那么携带该属性的路由不会在该联邦内传递,即不会在联邦子AS之间传递,但是可以在本子AS内传递)。



调试:


首先我们把R4R3R5配置成联邦AS 100,以便后面的测试。


这里我们做以下修改:


R1(config)#router bgp 10

R1(config-router)#neighbor 13.1.1.3remote-as 100


R2(config)#router bgp 10

R2(config-router)#neighbor 24.1.1.4remote-as 100


R3(config)#router bgp 50  

R3(config-router)#bgp confederationidentifier 100

R3(config-router)#bgp confederation peers30


R4(config)#router bgp 30

R4(config-router)#bgp confederationidentifier 100

R4(config-router)#bgp confederation peers50


然后在R1上做以下配置,即让R1通告1.1.1.0/24网段时,加上local-AS属性,配置如下:


R1(config)#access-list 13 permit 1.1.1.0

R1(config)#route-map 1-3 permit 10

R1(config-route-map)#match ip address 13

R1(config-route-map)#set community local-AS

R1(config-route-map)#exit

R1(config)#router bgp 10

R1(config-router)#neighbor 13.1.1.3 route-map1-3 out

R1(config-router)#neighbor 13.1.1.3send-community

R1(config-router)#end


为了看到实验效果我们分别在R3R5上面加上send-community


R3(config)#router bgp 50

R3(config-router)#neighbor 35.1.1.5send-community


R5(config)#router bgp 50

R5(config-router)#neighbor 45.1.1.4send-community



下面我们来查看社团属性的传递


R3#show ip bgp 1.1.1.0

BGP routing table entry for 1.1.1.0/24,version 14

Paths: (1 available, best #1, tableDefault-IP-Routing-Table, not advertised outside local AS)

Flag: 0x880

Advertised to non peer-group peers:

35.1.1.5

 10

  13.1.1.1 from 13.1.1.1 (1.1.1.1)

    Origin IGP, metric 0, localpref 100, valid, external, best

Community: local-AS


//此时,R3收到携带社团属性的1.1.1.0/24网段


R5#show ip bgp 1.1.1.0

BGP routing table entry for 1.1.1.0/24,version 6

Paths: (1 available, best #1, tableDefault-IP-Routing-Table, not advertised outside local AS)

 Notadvertised to any peer

 10

  13.1.1.1 (metric 128) from 35.1.1.3 (3.3.3.3)

    Origin IGP, metric 0, localpref 100, valid, internal, best

Community: local-AS


//同样,R5也收到携带社团属性的1.1.1.0/24网段


R4#show ip bgp        

BGP table version is 10, local router ID is4.4.4.4

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

             r RIB-failure, S Stale

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


 Network          Next Hop            Metric LocPrf Weight Path

*> 1.1.1.0/24      24.1.1.2                              0 10 i

*> 2.2.2.0/24       24.1.1.2                 0             0 10 i

*> 3.3.3.0/24       45.1.1.5                               0 50 i

*> 4.4.4.0/24       0.0.0.0                  0         32768 i

*> 5.5.5.0/24       45.1.1.5                 0             0 50 i


//我们发现,现在R4虽然学习到了1.1.1.0/24网段,但是其下一跳是24.1.1.2,即R2;也就是说,R4并没有收到来自R5BGP更新



从上面三个表中可以得出结论:R3R5都收到了被标记为local-AS1.1.1.0/24的路由条目,而R4只收到了下一跳为24.1.1.2的路由条目,说明R5没有把路由更新发送给R4。这里就说明了被标记为local-AS社团属性的条目只会在同一个AS内传递,如果对等体是一个联邦AS,那么也只能在该联邦子AS内传递。