当前位置:文档之家› BGP-community

BGP-community

BGP-community
BGP-community

community属性。这是不同于选路属性的一个属性。该属性具有以下几个特点:

1 community是一个任选可透明传送属性,它可以简化策略的执行。

2 它是cisco的一个专有属性,现在在RFC1997中已被标准化。

3 commnity属性标明一个目的地作为一些目的地团体中的一个成员,这些目的地共享一个或多个共同的特性。

NO_EXPORT:带有这一团体值的路由在收到后,不应把该路由通告给一个联盟之外的对等体。

NO_ADVERTISE:带有这一团体值的路由在收到后,不应把该路由通告给任何的BGP对等体。

LOCAL-AS:带有这一团体值的路由在收到后,可以把该路由通告给它的IBGP对等体,但不应通告给任何的EBGP对等体(包括联盟内的EBGP对等体)。

INTERNET:带有这一团体值的路由在收到后,可以通告给所有的其他路由器。

4 community值可以自己定义,另外有几个已经定义好的团体属性:

NO_ADVERTIS E:表示携带该值的路由不能公布给E BGP和 IBGP邻居

NO_EXPORT:表示携带该值的路由不能公布给E BGP邻居

LOCAL_AS:(NO_E XPORT_S UBCONFED)携带该值的路由可以公布给联盟内的其它子自治系统但不能在构成联盟的AS以外进行公布。

试验步骤如下:

配置BGP,在本实验中要建立联邦我们顺便学习一下联邦

配置团体属性,让2.2.2.0网络只被R2学习到

配置团体属性,让22.22.22.0网络只被R2,R3学习到

配置团体属性,让222.222.222.0网络只被R2,R3,R4学习到

配置团体属性,让R1不传递2.2.2.0 这条路由

二试验配置

配置BGP

r1#sh run | b r b

router bgp 100

no synchronization

network 2.2.2.0 mask 255.255.255.0

network 22.22.22.0 mask 255.255.255.0

network 222.222.222.0

neighbor 12.0.0.2 remote-as 234

no auto-summary

r2#sh run | b r b

router bgp 64512

no synchronization

bgp confederation identifier 234 /指明联邦号是234

neighbor 12.0.0.1 remote-as 100

neighbor 23.0.0.3 remote-as 64512 /R3跟它处于联邦内同一个子AS中

neighbor 23.0.0.3 next-hop-self /指定下一跳是它自己

no auto-summary

r3#sh run | b r b

router bgp 64512

no synchronization

bgp confederation identifier 234

bgp confederation peers 64513 /指明该联邦内的另一个子AS

neighbor 23.0.0.2 remote-as 64512

neighbor 34.0.0.4 remote-as 64513 /R4跟它处于联邦内不同子AS之间

no auto-summary

r4#sh run | b r b

router bgp 64513

no synchronization

bgp confederation identifier 234

bgp confederation peers 64512

neighbor 34.0.0.3 remote-as 64512

neighbor 45.0.0.5 remote-as 500

no auto-summary

r5#sh run | b r b

router bgp 500

no synchronization

neighbor 45.0.0.4 remote-as 234

no auto-summary

查看网络

r2#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*> 2.2.2.0/24 12.0.0.1 0 0 100 i

*> 22.22.22.0/24 12.0.0.1 0 0 100 i

*> 222.222.222.0 12.0.0.1 0 0 100 i

r3#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*>i2.2.2.0/24 23.0.0.2 0 100 0 100 i

*>i22.22.22.0/24 23.0.0.2 0 100 0 100 i

*>i222.222.222.0 23.0.0.2 0 100 0 100 i

在R2上已经修改了下一跳,所以这时下一跳已经是R2自己了。

r4#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

* 2.2.2.0/24 23.0.0.2 0 100 0 (64512) 100 i

* 22.22.22.0/24 23.0.0.2 0 100 0 (64512) 100 i

* 222.222.222.0 23.0.0.2 0 100 0 (64512) 100 i

注意在R4上看,下一跳依然是R2;为什么不是R3呢?因为R3,R4虽然在同一联邦内,但它们在不同的子AS之间,应该是E BGP关系。E BGP之间传递路由时,下一跳因该是E BGP邻居。但这里为什么不是呢。这就是联邦内E BGP与联邦外E BGP的不同之处。所以现在这些路由的下一跳对于R4来说是不可达的,所以现在路由无法优化,也就无法向R5传递。现在在R3上修改下一跳

r3(config)#router bgp 64512

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

r4#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*> 2.2.2.0/24 34.0.0.3 0 100 0 (64512) 100 i

*> 22.22.22.0/24 34.0.0.3 0 100 0 (64512) 100 i

*> 222.222.222.0 34.0.0.3 0 100 0 (64512) 100 i

这时,在R4上看,下一跳已经变成了R3,路由可以优化。注意在AS路径中可以看到路由经过了子AS 64512

r5#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*> 2.2.2.0/24 45.0.0.4 0 234 100 i

*> 22.22.22.0/24 45.0.0.4 0 234 100 i

*> 222.222.222.0 45.0.0.4 0 234 100 i

R5上也可以收到这些路由了,注意R5的AS路径看不到子AS ,只能看到联邦的总AS号。因此可以得出这样的结论:联邦内的子AS对于联邦外部来说是隐藏的,不可见的。

到现在为止,所有路由器都可以学习到路由,下面就要应用团体属性来控制路由的传递了。

三配置团体属性,让2.2.2.0网络只被R2学习到

这里最合适的community属性应该是:no_advertise 因为它不会向任何E BGP IBGP邻居公布路由。

r1(config)#access-list 1 permit 2.2.2.0 0.0.0.255 /用ACL匹配该路由

r1(config)#route-map WY permit 10

r1(config-route-map)#match ip add 1

r1(config-route-map)#set community no-advertise /设定团体属性

r1(config)#route-map WY permit 20 /与ACL一样 route-map最后也隐藏了一句deny any ,所以在这里要允许所有,要不然其它两条路由会因为匹配不上而无法从R1传递出去。

r1(config)#router bgp 100

r1(config-router)#neighbor 12.0.0.2 route-map WY out /在进程下出方向调用route-map

r1(config-router)#neighbor 12.0.0.2 send-community /让R2传递该社团属性

先在R2上进行查看;

r2#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*> 2.2.2.0/24 12.0.0.1 0 0 100 i

*> 22.22.22.0/24 12.0.0.1 0 0 100 i

*> 222.222.222.0 12.0.0.1 0 0 100 i

R2可以学习到该路由

在R3上查看

r3#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*>i22.22.22.0/24 23.0.0.2 0 100 0 100 i

*>i222.222.222.0 23.0.0.2 0 100 0 100 i

可以看到R3已经收不到2.2.2.0这个网络了,往后的路由器也无法收到了。所以社团属性

No_advertise 满足了只让R2学到该路由的需求。

四配置团体属性,让22.22.22.0网络只被R2,R3学习到

因为R2,R3处于联邦内同一个子AS,意思是该路由不能传递出这个子AS,所以可以用

community属性:LOCAL_AS

r1(config)#access-list 2 permit 22.22.22.0 0.0.0.255

r1(config)#route-map WY permit 10

r1(config-route-map)#match ip add 2

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

r1(config)#route-map WY permit 20

现在进行查看

r2#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*> 2.2.2.0/24 12.0.0.1 0 0 100 i

*> 22.22.22.0/24 12.0.0.1 0 0 100 i

*> 222.222.222.0 12.0.0.1 0 0 100 i

R2可以学习到。

r3#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*>i2.2.2.0/24 23.0.0.2 0 100 0 100 i

*>i22.22.22.0/24 23.0.0.2 0 100 0 100 i

*>i222.222.222.0 23.0.0.2 0 100 0 100 i

R3也可以学到

r4#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*> 2.2.2.0/24 34.0.0.3 0 100 0 (64512) 100 i

*> 22.22.22.0/24 34.0.0.3 0 100 0 (64512) 100 i

*> 222.222.222.0 34.0.0.3 0 100 0 (64512) 100 i

为什么R4依然可以学习到,难道属性没起作用吗?显然属性没有起作用,这是因为R2向R3传递该路由时没有让R3继承这个属性,所以R4依然可以学习到,现在必须在R2上配置让R3继承这个属性,这样R3向R4传递路由时团体属性才能生效。

r2(config)#router bgp 64512

r2(config-router)#neighbor 23.0.0.3 send-community

在R2上配置让R3继承该属性

r4#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*> 2.2.2.0/24 34.0.0.3 0 100 0 (64512) 100 i

*> 222.222.222.0 34.0.0.3 0 100 0 (64512) 100 i

现在R4就收不到这条路由了,R5当然也收不到,LOCAL_AS团体属性满足了这个需求。

五配置团体属性,让222.222.222.0网络只被R2,R3,R4学习到

这个需求意思是让这条路由不传到联邦外(大AS之外),所以要用NO_E XPORT属性

r1(config)#access-list 3 permit 222.222.222.0 0.0.0.255

r1(config)#route-map WY permit 10

r1(config-route-map)#match ip add 3

r1(config-route-map)#set community no-export

r1(config)#route-map WY permit 20

为了让R4能继承到该属性,必须在R1,R2,R3都配置send-community以便让该属性进行传递。在配置了传递属性之后,现在进行查看

r4#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*> 2.2.2.0/24 34.0.0.3 0 100 0 (64512) 100 i

*> 22.22.22.0/24 34.0.0.3 0 100 0 (64512) 100 i

*> 222.222.222.0 34.0.0.3 0 100 0 (64512) 100 i

R4可以收到

r5#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*> 2.2.2.0/24 45.0.0.4 0 234 100 i

*> 22.22.22.0/24 45.0.0.4 0 234 100 i

R5已经学习不到222.222.222.0了。需求满足。

但上面的做法有一个明显的缺点就是要在R1,R2,R3上配置传递该属性,比较麻烦。

现在用另一种比较简单的方法。

在R4上直接进行配置。

r4(config)#access-list 1 permit 222.222.222.0 0.0.0.255

r4(config)#route-map WY permit 10

r4(config-route-map)#match ip add 1

r4(config-route-map)#set community no-export

r4(config)#route-map WY permit 20

r4(config)#router bgp 64513

r4(config-router)#neighbor 34.0.0.3 route-map WY in

指定R3向R4传递路由时应用该route-map,所以是in方向的。

现在在R5上进行查看

r5#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*> 2.2.2.0/24 45.0.0.4 0 234 100 i

*> 22.22.22.0/24 45.0.0.4 0 234 100 i

这时,R5已经学习不到这条路由了,可见这种做法也起了作用

相关主题
文本预览
相关文档 最新文档