admin管理员组文章数量:1626223
COMMUNITY——可选传递属性
一种标记,用于简化路由策略的执行
可以将某些路由分配一个特定的community属性,之后就可以基于该community值而不是每条路由进行BGP属性设置
community属性就可以理解成在IGP内打TAG的意思,只不过在BGP中是community值
community值会一直传递下去,如果不做策略,永远不会丢失。
community属性在cisco路由器有两种表现形式:
Cisco路由器默认表现形式是十进制的形式,例如图片中:796432
RFC格式:AA:NN的形式
很明显RFC的AA:NN的格式更直观对吧 AA可以表示AS号,NN可以表示序列号
而且两种格式在正则表达式中的应用也会有所不同,因为这是完全两种不一样的值,正则表达式的写法也就不一样
R1(config)#ip bgp-community new-format
用上边的命令修改格式
Community属性配置方法:
R1(config)#ip community-list standard COMMUNITY permit 100:10
全局配置用community-list匹配community值,permit 100:10就是去permit一个带100:10的community值的路由。
在Route-map中去配置community属性
你match一个community列表后打一问号回有一个可选项,这个叫严格匹,community在match时有严格匹配和宽松匹配两种模式,严格匹配就是去严格的执行community-list所permit的那些community值,具体的在下边实验体现,我会专门跟据这个严格匹配做一个实验
R1(config)#route-map test permit 10
R1(config-route-map)#match community COMMUNITY ?
exact-match Do exact matching of communities 严格匹配最后有讲到
在Route-map中去set那个community属性时,打个问号会有很多可选项,下边实验我们一一的介绍这些可选项的使用方法
R1(config-route-map)#set community ? set community值
<1-4294967295> community number
aa:nn community number in aa:nn format
additive Add to the existing 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
internet Internet (well-known community)
additive:再原有的community属性上,再增加一个community值,后边要加上additive关键字,如果不加,就会覆盖掉先前的community值。这个关键字是整个community属性我个人觉得是最重要的一个关键字了
Internet:默认所有路由都属于该可选项,可以匹配路由表中所有的路由前缀,给他们标记community值。(正常情况我们是先用ACL或prefix-list(前缀列表)匹配出想要的路由,然后调用它为它标记community值,如果你不先用ACL去抓路由,想把路由表中所有路由前缀一并标记community值,就可以set这个可选项
local-AS:不传出本AS自治系统,如果定义了联邦可以在联邦内传递。(联邦就是在一个AS自治系统内定义多个小AS自治系统)
no-advertise:不将路由传递任何BGP邻居
no-export:不传递给任何EBGP邻居(联邦EBGP邻居除外)
none:不携带任何的Community值
全篇的IP地址规划:192.168.xy.z 其中x是较小设备编号,y是较大设备编号,z是本设备编号 例如:R1---R2 R1的IP:192.168.12.1 R2的IP:192.168.12.2 所有路由器均有loopback0接口 R1是1.1.1.1/32 类推
全篇不再赘述IP地址规划,邻居可以根据拓扑可以看出哪些是EBGP,哪些是IBGP邻居,也不再赘述
需求:1. R1路由器向EBGP邻居R2通告了两条路由前缀,我们为172.16.1.0/24路由前缀标记一个community属性值
2.在R2路由器利用标记了community属性值的路由针对邻居R4做路由策略,为了方便实验效果,在R2针对标记community属性值修改local-preference属性(因为local-preference属性它默认值是100,我们调整成200)
R1(config)#ip prefix-list 10 permit 172.16.1.0/24 抓取172.16.1.0/24路由,注意我只抓了这一个路由并没有172.16.2.0/24路由
R1(config)#route-map test permit 10 创建Route-map,取名test
R1(config-route-map)#match ip address prefix-list 10 match那个前缀列表
R1(config-route-map)#set community 100:10 分配一个100:10的 community属性值
R1(config)#route-map test permit 20 Router-map隐含deny,所以写一条空的Router-map语句,空Router-map等同于permit any。你如果不写,那么其他路由将会被最后隐含的deny 所匹配
R1(config-route-map)#exit
R1(config)#router bgp 100
R1(config-router)#network 172.16.1.0 mask 255.255.255.0
R1(config-router)#network 172.16.2.0 mask 255.255.255.0
R1(config-router)#neighbor 192.168.12.2 route-map test out 针对邻居应用Router-map
R1(config-router)#neighbor 192.168.12.2 send-community Send-community属性,你不send邻居它是收不到任何community值。比如,R1上边为X路由标记100:10,你假设不去send,那R2路由器,它不是说看不到这条路由,而是看不到这个100:10的community值。你要传递给邻居,你就要send一下这个属性
R2#show ip bgp 172.16.1.0 在R2路由器查看172.16.1.0/24路由详细信息
BGP routing table entry for 172.16.1.0/24, version 9
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x8A0
Advertised to update-groups:
2
100
192.168.12.1 from 192.168.12.1 (1.1.1.1)
Origin IGP, metric 0, localpref 100, valid, external, best
Community: 100:10 最后有一个Community: 100:10的信息
R2(config)#ip community-list standard COMMUNITY permit 100:10 创建 community-list抓取Community
版权声明:本文标题:BGP中COMMUNITY属性 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1728943750a1181004.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论