communitycommunityBGP
communityIGPTAGBGPcommunity值
community
communitycisco
Cisco796432
RFCAANN
RFCAANNASNN
R1(config)#ip bgp-community new-format
Community
R1(config)#ip community-list standard COMMUNITY permit 10010
community-listcommunity
Route-mapcommunity
matchcommunitycommunitymatch
R1(config)#route-map test permit 10
?
Route-mapsetcommunity
R1(config-route-map)#set community 值
additivecommunitycommunityadditivecommunity值。这个关键字是整个community属性我个人觉得是最重要的一个关键字了
InternetcommunityACLprefix-listcommunityACLcommunityset
local-ASASASAS
no-advertiseBGP
no-exportEBGPEBGP邻居
noneCommunity值
全篇不再赘述IP地址规划,邻居可以根据拓扑可以看出哪些是EBGP,哪些是IBGP邻居,也不再赘述
1. R1EBGPR2172.16.1.0/24community
2.R2communityR4R2communitylocal-preferencelocal-preference100200
R1(config)#route-map test permit 10Route-map,test
R1(config-route-map)#match ip address prefix-list 10
community
R1(config)#router bgp 100
R1(config-router)#network 172.16.2.0 mask 255.255.255.0
Router-map
R1(config-router)#neighbor 192.168.12.2 send-community
R2#show ip bgp 172.16.1.0R2172.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
Community: 100:10Community: 100:10
R2(config)#ip community-list standard COMMUNITY permit 100:10 community-list抓取CommunityCommunitycommunity-list
Route-m
R2(config-route-map)#match community COMMUNITY ommunity-lis
R2(config-routlocal-preference200
deny
R2(config-route-map)#exit
R2(config)#router bgp 200
Router-map
R4#show ip bgp R4
BGP table version is 10, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
LocPrf Weight Path
200
R4172.16.1.0/24local-preference172.16.1.0/24local-preference100
R210010communitycommunity20023community值
Additive communitycommunity值
R2(config)#ip community-list standard COMMUNITY permit 100:10
R2(config)#route-map test permit 10
R2(config-route-map)#match community COMMUNITY
R2(config-route-map)#set community 200communitycommunityadditive10010ֵ
Route-map
R2(config-route-map)#exit
R2(config)#router bgp 23
Route-map
R4#show ip bgp 172.16.1.0
BGP routing table entry for 172.16.1.0/24, version 6
Paths: (1 available, best #1, table Default-IP-Routing-Table)
20023
R2no-advertiseR4no-advertiseBGP
no-advertise
R2(config)#ip community-list standard COMMUNITY permit 100:10
R2(config)#route-map test permit 10
R2(config-route-map)#match community COMMUNITY
R2(config-route-map)#set community no-advertise10010200:23 涓や釜
Route-map
R2(config-route-map)#exit
R2(config)#router bgp 23
Route-map
R4#show ip bgp 172.16.1.0R4
BGP routing table entry for 172.16.1.0/24, version 17
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to any peer)
Flag: 0x820
Community: 100:10 200:23 no-advertiseno-advertise
R5#show ip bgp
BGP table version is 26, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
R6#show ip bgp
BGP table version is 26, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
R4no-advertisecommunity R4R5172.16.1.0/24,R6
R1R2是EBGPR4R5R6EBGP
R2no-exportR4EBGPEBGP
no-export
R2(config)#ip community-list standard COMMUNITY permit 100:10
R2(config)#route-map test permit 10
R2(config-route-map)#match community COMMUNITY
additive
Route-map
R2(config-route-map)#exit
R2(config)#router bgp 23
R2(config-router)#neighbor 4.4.4.4 route-map test out
R5#show ip bgp
BGP table version is 33, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
R5R4EBGP172.16.1.0/24172.16.2.0/24
R6#show ip bgp
BGP table version is 29, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
R6R4EBGP172.16.1.0/24
R2noneCommunity值
R2172.16.1.0/2410010communityR1
none
R2(config)#ip community-list standard COMMUNITY permit 100:10
R2(config)#route-map test permit 10
R2(config-route-map)# match community COMMUNITY
R2(config-route-map)#set community 200:23 additiveadditive
R2(config-route-map)#R2community值
R2(config-route-map)#set local-preference 200
Route-map
R2(config-route-map)#exit
R2(config)#router bgp 23
R2(config-router)#neighbor 4.4.4.4 route-map test out
R4#show ip bgp 172.16.1.0
BGP routing table entry for 172.16.1.0/24, version 29
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x880
R2172.16.1.0/2420023CommunityR420023Community10010CommunityR2additive 100:10Community值R1 R2R4Community
R2Loopbackkcal-ASASEBGPASAS
Loopbackkcal-AS
R2(config)#ip community-list standard COMMUNITY permit 100:10
R2(config)#route-map test permit 10
R2(config-route-map)# match community COMMUNITY
additive
R2(config-route-map)#local-AS
R2(config-route-map)#set local-preference 200
R2(config-route-map)#exit
Route-map
R2(config-route-map)#exit
R2(config)#router bgp 23
R2(config-router)#neighbor 4.4.4.4 route-map test out
R4#show ip bgp
BGP table version is 10, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
R4R2EBGPASAS
R6#show ip bgp
BGP table version is 38, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
R6AS172.16.1.0/24
R15loopbackR1loopback172.16.1.0/2410010 community10020 community
InternetRoute-mapRoute-mappermit anyany Internet
Internetcommunity
R1(config)#ip prefix-list 10
R1(config)#route-map test permit 10
R1(config-route-map)#match ip address prefix-list 10
community值10010
R1(config-route-map)#exit
Route-maptest
Route-map
R2(config)#ip community-list standard COMMUNITY permit 100100
R2(config)#route-map test permit 10
R2(config-route-map)#match community COMMUNITY
BGPMED
Route-map
R2(config-route-map)#exit
R2(config)#router bgp 200
R2(config-router)#neighbor 4.4.4.4 route-map test out
R4#show ip bgp
BGP table version is 35, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S Stale
2000
2000
2000
一共做了六个实验,分别把Route-map中去set community属性的几个可选参数全部做了一遍
下边讲community-list在匹配的时候匹配规则,就是当一个路由携带多个community值的时候,你怎么写community-list列表才能去匹配住那个路由
R1(config)#ip community-list standard name permit 100:10 100:10 local-AS community-listNcommunity
R1172.16.1.0/24R21001010011community值
R2communitycommunity-list
community-listcommunity
R1(config)#ip prefix-list 10 permit 172.16.1.0/24
R1(config-route-map)#match ip address prefix-list 10
R1(config-route-map)#exit
R1(config)#route-map test permit 20
R1(config-route-map)#exit
R2(config)#ip community-list standard COMMUNITY permit 100:10 100community-list10020R1 set10011
R2(config)#route-map test permit 10
R2(config-route-map)#match community COMMUNITY
local-preference
Route-map
R2(config-route-map)#exit
R2(config)#router bgp 200
R2(config-router)#neighbor 3.3.3.3 route-map test out
BGP table version is 41, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
100
R2local-preference
community-listcommunity-list
community
R2(config)#ip community-list standard COMMUNITY R2community-list
R2(config)#route-map test permit 10
R2(config-route-map)#match community COMMUNITY
local-preference
Route-map
R2(config-route-map)#exit
R2(config)#router bgp 200
R2(config-router)#neighbor 3.3.3.3 route-map test out
BGP table version is 41, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
200
local-preference
总结:community-listcommunitycommunity-list
community-list
Route-mapmatchcommunity
R1R2loopback1loopback2communityR2
R1(config)#ip prefix-list 10 permit 172.16.1.0/24
R1(config)#ip prefix-list 20 permit 172.16.2.0/24
R1(config)#route-map test permit 10
R1(config-route-map)#match ip address prefix-list 10
loopback1set10010
R1(config-route-map)#exit
R1(config)#route-map test permit 20
R1(config-route-map)#match ip address prefix-list 20
R1(config-route-map)#set community 100:10 100set
R1(config-route-map)#exit
R1(config-route-map)#exit
R1(config)#router bgp 100
R2(config)#ip community-list standard COMMUNITY community-listpermit10010community值
R2(config)#route-map test permit 10
R2(config-route-map)#match community COMMUNITY
local-preference200
R2(config)#route-map test permit 20
R2(config-route-map)#exit
R2(config)#router bgp 200
R2(config-router)#neighbor 3.3.3.3 route-map test out
BGP table version is 41, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
200
local-preferenceR2community-list10010community10010communitylocal-preference
R2(config)#ip community-list standard COMMUNITY permit 100:10
R2(config)#route-map test permit 10
R2(config-route-map)#match community COMMUNITY exact-match
local-preference200
R2(config)#route-map test permit 20
R2(config-route-map)#exit
R2(config)#router bgp 200
R2(config-router)#neighbor 3.3.3.3 route-map test out
BGP table version is 41, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
Origin codes: i - IGP, e - EGP, ? - incomplete
200
172.16.1.0/24local-preference172.16.2.0/24
matchexact-matchcommunity-listcommunity
community-listR210010
community172.16.1.0/2410010172.16.2.0/241001010020communitymatch
R1172.16.2.0/24community1001010020R2communitycommunity值
community值
R2(config)#ip community-list standard COMMUNITY permit 100:20 community
Route-map
R2(config-route-map)#set comm-list community setcommunity
R2(config-route-map)#exit
R2(config)#router bgp 200
R2(config-router)#neighbor 3.3.3.3 route-map test out
R3#show ip bgp 172.16.2.0
BGP routing table entry for 172.16.1.0/24, version 38
Paths: (1 available, best #1, table Default-IP-Routing-Table)
R1172.16.2.0/24community1001010020R2communitycommunity值
community值
R2(config)#ip community-list standard COMMUNITY permit 100:10 community
R2(config)#ip community-list standard COMMUNITY permit 100:20 community-list
Route-map
R2(config-route-map)#set comm-list community setcommunity
R2(config-route-map)#exit
R2(config)#router bgp 200
R2(config-router)#neighbor 3.3.3.3 route-map test out
R3#show ip bgp 172.16.2.0
BGP routing table entry for 172.16.1.0/24, version 38
Paths: (1 available, best #1, table Default-IP-Routing-Table)
R2communitycommunitycommunity-list
community
BGPRoute-map
Route-mapnetworkRoute-map
Route-map
networkneighbornetworkneighbor
原文:http://blog.51cto.com/13595867/2132137