BGP community属性

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

BGP community属性无敌详解文档(视频详解+配套文档)

community属性是BGP众多路径属性中一个相对比较难理解的知识点,需要通过大量实验加深印象,为了帮助大家更清晰的了解这个路径属性,我特定编写了这份文档,希望对大家有所帮助。

本文档配套详解视频:

1、community的基本概念

可选传递,用于简化路由策略的执行。可以将某些路由分配一个特定的COMMUNITY 属性,之后就可以基于COMMUNITY值而不是每条路由进行BGP属性的设置了。COMMUNITY属性对邻居起作用,在设置后,同时需要向邻居发送(send community,默认是不会发送的)。

COMMUNITY属性是一组4个8位组的数值,RFC1997规定前2B表示AS号,后2B 表示基于管理目的设置的标示符,格式为AA:NN,而CISCO默认显示格式为NN:AA (CISCO IOS在显示community值时,默认是按10进制格式显示),可使用全局配置命令ip bgpcommunity new-format将CISCO默认格式改为RFC格式。

例如将AS12的某条路由COMM值改为10000,RFC采用十六进制表示COMMUNITY属性,而CISCO采用十进制。RFC格式为12:10000,十六进制为0x 000C2710,再转换为十进制796432(这就是CISCO IOS默认显示的值)。

抓个包看一下:

2、在route-map中设置community属性

route-map test permit 10

set community ?

<1-4294967295> community number

aa:nn community number in aa:nn format

additive Add to the existing community 设置commu值为附加,否则为覆盖 internet Internet (well-known community) 默认所有路由都属于该团体

local-AS Do not send outside local AS (well-known community)

no-advertise Do not advertise to any peer (well-known community)

no-export Do not export to next AS (well-known community)

none No community attribute

下边我们来看一下community的这几个众所周知值的本文为原创博文,

no-advertise

no-export

local-as

配置示例(使用route-map为路由分配community):

在R1上为路由11.11.11.0/24分配community 100:11,并且传递给R2,那么R1上配

置如下:

ip prefix-list 11 permit 11.11.11.0/24

route-map test permit 10

match ip address prefix-list 11

set community 100:11

router bgp 100

network 11.11.11.0 mask 255.255.255.0

neighbor 10.1.12.2 remote-as 200

neighbor 10.1.12.2 send-community // 默认community不发送,因此必须配置该

命令

neighbor 10.1.12.2 route-map test out

注意community默认不发送,必须send-community。

另外一条路由前缀可以携带多个community形成一个列表,如果要针对特定路由在原

有的community基础之上再增加一个community,则在route-map中set community时,增加additive关键字。

3、使用ip community-list匹配community值

ip community-list ?

<1-99> Community list number (standard)

<100-500> Community list number (expanded)

expanded Add an expanded community-list entry

standard Add a standard community-list entry

ip community-list 也像ACL那样,有标准和扩展之分,1-99为标准,100-199为扩展。扩展的community-list 可以使用正则表达式匹配路由。

这里有一点需要注意,ip bgp-community new-format用于转换community在CISCO IOS中的显示格式,当在扩展的community-list列表中使用正则表达式的过滤结果会由于格式的选择不同而不同。

ip community-list示例1

在上面实验的基础上,R1传递给R2的11.11.11.0/24路由,携带了community值100:11,这个值可以在R2上使用ip community-list进行匹配,从而可以进一步在route-map中用这个community-list去设置策略。我们现在在R2上用community-list 去匹配100:11,通知添加一个no-export的community到该路由。

R2的配置如下:

ip community-list 11 permit 100:11

route-map test permit 10

match community 11

set community no-export additive

router bgp 200

neighbor 10.1.12.1 remote-as 100

neighbor 10.1.23.3 remote-as 300

neighbor 10.1.23.3 send-community

neighbor 10.1.23.3 route-map test out

R3上show ip bgp 11.11.11.0

BGP routing table entry for 11.11.11.0/24, version 5

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

Flag: 0x820

Not advertised to any peer

相关文档
最新文档