BGP中COMMUNITY屬性

COMMUNITY——可選傳遞屬性

一種標記,用於簡化路由策略的執行

可以將某些路由分配一個特定的community屬性,之後就可以基於該community值而不是每條路由進行BGP屬性設置

community屬性就可以理解成在IGP內打TAG的意思,只不過在BGP中是community

community值會一直傳遞下去,如果不做策略,永遠不會丟失。

 

community屬性在cisco路由器有兩種表現形式:


1.png 

 

Cisco路由器默認表現形式是十進制的形式,例如圖片中:796432

RFC格式:AANN的形式

很明顯RFCAANN的格式更直觀對吧    AA可以表示AS號,NN可以表示序列號

而且兩種格式在正則表達式中的應用也會有所不同,因爲這是完全兩種不一樣的值,正則表達式的寫法也就不一樣

R1(config)#ip bgp-community new-format

用上邊的命令修改格式

 

 

Community屬性配置方法:

R1(config)#ip community-list standard COMMUNITY permit 10010

全局配置用community-list匹配community值,permit 10010就是去permit一個帶100:10的community值的路由。

 

Route-map中去配置community屬性

match一個community列表後打一問號回有一個可選項,這個叫嚴格匹,communitymatch時有嚴格匹配和寬鬆匹配兩種模式,嚴格匹配就是去嚴格的執行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值。(正常情況我們是先用ACLprefix-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鄰居,也不再贅述

 

 2.png

 

需求: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屬性路由,匹配Community屬性使用community-list匹配的

R2(config)#route-map test permit 10                                                            創建Route-map,取名test

R2(config-route-map)#match community COMMUNITY                                           match那個community-list列表

R2(config-route-map)#set local-preference 200                                                         修改local-preference屬性值爲200

R2(config)#route-map test permit 20                                                                           Router-map隱含deny,所以寫一條空的

R2(config-route-map)#exit

R2(config)#router bgp 200

R2(config-router)#neighbor 4.4.4.4 route-map Community out         針對鄰居應用Router-map語句

R2(config-router)#neighbor 4.4.4.4 send-community                          Send-community屬性,使得該屬性生效

 

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,

              r RIB-failure, S Stale

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

 

   Network          Next Hop            Metric LocPrf Weight Path

*>i172.16.1.0/24    2.2.2.2                  0    200      0 100 i

*>i172.16.2.0/24    2.2.2.2                  0    100      0 100 i

R4路由器關於172.16.1.0/24local-preference屬性生效了,172.16.1.0/24local-preference屬性還是默認值100



3.png

 

需求:R2路由器已經通過上邊實驗有了一個10010community值,然後在原有的community值上在添加一個新的20023community

 

Additive可選項使用規則: 再原有的community屬性上,再增加一個community

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 20023 additive      再原有的community屬性上,再增加一個community值,後邊要加上additive關鍵字,如果不加,就會覆蓋掉先前的10010值

R2(config)#route-map test permit 20                           寫一個空的Route-map,放行其他的路由

R2(config-route-map)#exit

R2(config)#router bgp 23

R2(config-router)#neighbor 4.4.4.4 route-map COMMUNITY out              針對鄰居調用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)

  Advertised to update-groups:

        2    3

  (23) 100

    2.2.2.2 (metric 156160) from 2.2.2.2 (2.2.2.2)

      Origin IGP, metric 0, localpref 200, valid, confed-external, best

      Community: 100:10 200:23                Community後邊多了一個20023的屬性值,說明成功了

 

4.png


上圖定義了聯邦,AS號標識的很清楚BGP的鄰居關係

需求:在R2上部署no-advertise關鍵字,讓R4路由器在收到帶有no-advertise關鍵字時,不將路由傳遞給任何BGP鄰居

 

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-advertise additive            additive關鍵字要加,不加先前10010200:23 兩個  community屬性值就會丟失了

R2(config)#route-map test permit 20                                                    寫一個空的Route-map,放行其他的路由

R2(config-route-map)#exit

R2(config)#router bgp 23

R2(config-router)#neighbor 4.4.4.4 route-map test out                  針對鄰居調用Route-map

 

 

R4#show ip bgp 172.16.1.0                                      R4路由器觀察現象

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

  Not advertised to any peer

  (23) 100

    2.2.2.2 (metric 156160) from 2.2.2.2 (2.2.2.2)

      Origin IGP, metric 0, localpref 200, valid, confed-external, best

      Community: 100:10 200:23 no-advertise                  多了一個no-advertise可選參數,並且先前200:23都還在,因爲加了additive關鍵字

 

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,

              r RIB-failure, S Stale

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

 

   Network          Next Hop            Metric LocPrf Weight Path

*>i172.16.2.0/24        2.2.2.2            0    100      0 (23) 100 i    

 

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,

              r RIB-failure, S Stale

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

 

   Network          Next Hop            Metric LocPrf Weight Path

*>i172.16.2.0/24       192.168.46.4         0     100  0 (23) 100 i

 

由於R4收到了一個帶no-advertise關鍵字的community 值路由,R4將不會在將該路由傳遞給任何鄰居,可以看到R5路由表丟失了172.16.1.0/24路由,R6同樣也沒有該路由前綴信息



5.png


環境:R1R2是EBGP鄰居            R2R4是聯邦EBGP           R4R5是聯邦EBGP                      R4R6EBGP

需求:在R2上部署no-export關鍵字,讓R4在收到該屬性不傳遞給任何EBGP鄰居(聯邦EBGP除外)

 

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

R2(config-route-map)#set community no-export                     additive 加上additive關鍵字要加,不加先前10010200:23 兩個  community屬性值就會丟失了

R2(config)#route-map test permit 20                          寫一個空的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,

              r RIB-failure, S Stale

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

 

   Network          Next Hop            Metric LocPrf Weight Path

*>i172.16.1.0/24    2.2.2.2                  0    200      0 (23) 100 i

*>i172.16.2.0/24    2.2.2.2                  0    100      0 (23) 100 i

R5作爲R4的聯邦EBGP鄰居,不會丟失172.16.1.0/24路由和172.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,

              r RIB-failure, S Stale

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

 

   Network          Next Hop            Metric LocPrf Weight Path

*> 172.16.2.0/24    192.168.46.4            0     100    100  i

R6作爲R4EBGP鄰居,丟失了172.16.1.0/24路由

 

4.png


需求:R2上使用none關鍵字,在向鄰居發送路由時不攜帶任何的Community

            注意:R2關於172.16.1.0/24先前實驗中有一個10010community值,是R1傳遞過來的

 

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 additive      加上additive關鍵字

R2(config-route-map)#set community none                        Set none屬性,使得R2在傳輸該路由前綴時不攜帶任何community

R2(config-route-map)#set local-preference 200

R2(config)#route-map test permit 20                                  寫一個空的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

  Advertised to update-groups:

        2    3

  (23) 100

    2.2.2.2 (metric 156160) from 2.2.2.2 (2.2.2.2)

      Origin IGP, metric 0, localpref 200, valid, confed-external, best

      Community: 100:10

R2明明也爲172.16.1.0/24路由標記了一個20023Community值,但是R4丟失了20023Community值,但是並未丟失10010Community值,因爲R2使用了additive關鍵字, 100:10CommunityR1路由器配置的所以不會丟失 。通過實驗可以看出R2在向R4傳遞路由時候是沒有攜帶任何的Community值。

 

4.png


需求:R2部署Loopbackkcal-AS關鍵字該屬性只能在本AS內傳遞,定義了聯邦則聯邦EBGP鄰居也能收到,但是無法傳出本AS,就是大AS自治系統

 

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

R2(config-route-map)#set community 200:23 additive                 加上additive關鍵字

R2(config-route-map)#set community local-AS                       set那個local-AS可選項

R2(config-route-map)#set local-preference 200

R2(config-route-map)#exit

R2(config)#route-map test permit 20                                                  寫一個空的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,

              r RIB-failure, S Stale

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

 

   Network          Next Hop            Metric LocPrf Weight Path

*>i172.16.1.0/24    2.2.2.2                  0    200      0 100 i

*>i172.16.2.0/24    2.2.2.2                  0    100      0 100 i

R4作爲R2的聯邦EBGP鄰居,雖然它們小AS號不同,但是它們同屬一個大AS自治系統,說白了還是一家人嘛

 

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,

              r RIB-failure, S Stale

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

   Network          Next Hop            Metric LocPrf Weight Path

*> 172.16.2.0/24    192.168.46.4             0    200   100    i

R6作爲其他AS自主系統,丟失了172.16.1.0/24路由

 

6.png


需求:R1路由器5loopback接口,假設R1還有很多很多loopback接口,只想對172.16.1.0/24路由標記10010 community值,剩下全部標記10020 community值。

Internet給我的感覺特別像空的Route-map,因爲空的Route-mappermit any的意思,any不就是匹配所有路由麼? Internet也是匹配所有路由。。。  還是挺繞的

 

Internet可選項使用規則:匹配路由表中所有路由前綴,一併標記community值。

R1(config)#ip prefix-list 10 permit 172.16.1.0/24                             抓取路由

R1(config)#route-map test permit 10

R1(config-route-map)#match ip address prefix-list 10

R1(config-route-map)#set community 100:10                                set一個community10010

R1(config-route-map)#exit

R1(config)#route-map test permit 20                                              創建Route-map,取名test

R1(config-route-map)#set community internet 100:100              匹配路由表中所有路由前綴

R1(config-route-map)#exit                                                                 這個時候就不用寫空的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

R2(config-route-map)#set community 200:23 additive  

R2(config-route-map)#set metric 2000                                       爲了實驗效果我們修改BGPMED屬性

R2(config)#route-map test permit 20                                           寫一個空的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

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

 

   Network          Next Hop          Metric     LocPrf  Weight Path

*> 172.16.1.0/24    2.2.2.2               0          100      0  100 i

*> 172.16.2.0/24    2.2.2.2               2000    100     0  100 i

*> 172.16.3.0/24    2.2.2.2               2000    100     0  100 i

*> 172.16.4.0/24    2.2.2.2               2000    100     0  100 i

 

 

上邊一共做了六個實驗,分別把Route-map中去set community屬性的幾個可選參數全部做了一遍

下邊講community-list在匹配的時候匹配規則,就是當一個路由攜帶多個community值的時候,你怎麼寫community-list列表才能去匹配住那個路由

 

 R1(config)#ip community-list standard name permit 100:10 100:10 local-AS ?        community-list在匹配的時候它可以在一行匹配Ncommunity值和下邊的參數

  <1-4294967295>  community number

  aa:nn           community number

  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)

 

7.png


環境:R1在將172.16.1.0/24路由通過給R2路由器時爲該路由分配了1001010011兩個個community

但是R2它要基於community值簡化配置,它的community-list要怎麼寫?

 

community-list匹配community屬性規則:


R1(config)#ip prefix-list 10 permit 172.16.1.0/24

R1(config)#route-map test permit 10  

R1(config-route-map)#match ip address prefix-list 10 

R1(config-route-map)#set community 100:10 100:11            分配了兩個community 值,注意下邊紅色的字體

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 10020          R2的community-list寫法一行同時寫了兩個,但是10020然而並不是R1 set10011

R2(config)#route-map test permit 10

R2(config-route-map)#match community COMMUNITY

R2(config-route-map)#set community additive             

R2(config-route-map)#set local-preference 200          爲了看效果,修改下local-preference屬性

R2(config)#route-map test permit 20                             寫一個空的Route-map,放行其它的路由

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           

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,

              r RIB-failure, S Stale

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

 

   Network          Next Hop          Metric  LocPrf   Weight  Path

*> 172.16.1.0/24       2.2.2.2            0      100      0     100 i

*> 172.16.2.0/24       2.2.2.2            0      100     0     100 i

可以看到剛纔R2設置的local-preference屬性並未生效,因爲local-preference屬性它默認值是100

由上可以看出community-list匹配規則是當要匹配的路由前綴攜帶多個community-list值時,

如果寫在一行只有全部的community值匹配正確,才能匹配上。

 

但是如果你是下邊的寫法:

R2(config)#ip community-list standard COMMUNITY permit 100:10         R2community-list寫法一行只寫了一個

R2(config)#route-map test permit 10

R2(config-route-map)#match community COMMUNITY

R2(config-route-map)#set community additive             

R2(config-route-map)#set local-preference 200          爲了看效果,修改下local-preference屬性

R2(config)#route-map test permit 20                             寫一個空的Route-map,放行其它的路由

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           

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,

              r RIB-failure, S Stale

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

 

   Network          Next Hop          Metric  LocPrf   Weight  Path

*> 172.16.1.0/24       2.2.2.2            0      200      0     100 i

*> 172.16.2.0/24       2.2.2.2            0      100     0     100 i

 R2local-preference屬性生效了


總結:community-list寫在一行寫多個community值的時候是一個且的關係,就是這一行的community值全部匹配上,這個community-list才能成真。

 

 

上邊就是community-list的匹配規則

下邊講Route-mapmatch那個community列表時的寬鬆和嚴格模式的規則

 

 8.png


環境:R1R2通告了兩條路由,分別是loopback1loopback2接口,並附帶上兩個不通的community值,具體附帶什麼看配置。    最關鍵的配置在R2路由器

 

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

R1(config-route-map)#set community 100:10              loopback1路由set的是10010的值

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 10020               loopback2路由set了兩個值

R1(config-route-map)#exit

R1(config)#route-map test permit 30                                                寫一個空Route-map

R1(config-route-map)#exit

R1(config)#router bgp 100

R1(config-router)#neighbor 192.168.12.2  route-map test out


 

R2(config)#ip community-list standard COMMUNITY permit 100:10              R2只permit10010community

R2(config)#route-map test permit 10

R2(config-route-map)#match community COMMUNITY

R2(config-route-map)#set local-preference 200                                            修改下local-preference屬性200待會看效果

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

 

R3#show ip bgp           

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,

              r RIB-failure, S Stale

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

 

   Network          Next Hop          Metric  LocPrf   Weight  Path

*> 172.16.1.0/24       2.2.2.2            0      200      0     100 i

*> 172.16.2.0/24       2.2.2.2            0      200     0     100 i

你會發現兩條路由都被修改了local-preference屬性值,因爲R2community-list的時候只匹配了10010這個community值,但是兩條路由都包含10010這個community值,所以都被修改了local-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          嚴格匹配關鍵字

R2(config-route-map)#set local-preference 200                                             修改下local-preference屬性200待會看效果

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

 

 

R3#show ip bgp           

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,

              r RIB-failure, S Stale

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

 

   Network          Next Hop          Metric  LocPrf   Weight  Path

*> 172.16.1.0/24       2.2.2.2            0      200      0     100 i

*> 172.16.2.0/24       2.2.2.2            0      100     0     100 i

 

只有172.16.1.0/24被修改了local-preference屬性值,這一次172.16.2.0/24並沒有修改

你一旦在match的時候加上exact-match嚴格匹配關鍵字,它一定會嚴格的按照你community-list列表上所以的community值進行匹配,多一點少一點都匹配不上。

在剛纔的community-list列表上R2它只寫了一個10010

但是這兩條路由所攜帶的community值只有172.16.1.0/24的是10010,所以它被匹配上了,而172.16.2.0/24它不但有10010它還有一個10020community值,這個時候它就不能被匹配上。這個就是在你match的時候嚴格匹配的意思

 

9.png 

 

需求:R1在上邊的配置對172.16.2.0/24配置了兩個community值一個是10010還有一個是10020,現在R2路由器它想刪除其中一個community值,讓我們看下如何刪除一個或多個community

 

刪除單個community

R2(config)#ip community-list standard COMMUNITY permit 100:20         把要刪的community值匹配出來

R2(config)#route-map test permit 10                                             創建Route-map

R2(config-route-map)#set comm-list community COMMUNITY                 直接set那個community列表

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)

  Advertised to update-groups:

        2    3

  (23) 100

    2.2.2.2 (metric 156160) from 2.2.2.2 (2.2.2.2)

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

      Community: 100:10                                                                      只有一個100:10的值,100:20的成功被刪除

 

9.png


需求:R1在上邊的配置對172.16.2.0/24配置了兩個community值一個是10010還有一個是10020,現在R2路由器它想刪除兩個個community值,讓我們看下如何刪除多個community


刪除多個community

R2(config)#ip community-list standard COMMUNITY permit 100:10 把要刪的community值匹配出來

R2(config)#ip community-list standard COMMUNITY permit 100:20 在寫一個要community-list

R2(config)#route-map test permit 10                     創建Route-map

R2(config-route-map)#set comm-list community COMMUNITY         直接set那個community列表

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)

  Advertised to update-groups:

        2    3

  (23) 100

    2.2.2.2 (metric 156160) from 2.2.2.2 (2.2.2.2)

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

可以看到R2成功的刪除了多個community值,其實刪除多個community值就是多寫一個community-list列表

 

整個community屬性就全部寫完了,其實寫這個還是挺累的,當中停了一次寫着寫着不知道要怎麼表達,因爲有些實驗它需要以視頻方式講解更能去表達一個人的意思,用文字寫,很囉嗦,尤其在這個快餐的時代,很少有人能夠靜下心來看完別人寫的整篇文章。關鍵我也不是專業寫這個的,有時候表達啊可能更願意按照自己的想法。

但是更多的還是要自己去實踐

 

BGP的環境下做路由策略,它很多中方式。我全篇都是針對鄰居做的Route-map

你可以針對特定的路由做Route-map(就是network後邊也能攜帶Route-map

重發布路由時也能攜帶Route-map

 

至於說的networkneighbor的區別就是,你如果是用network的方式那麼所有接收到該路由的鄰居都能夠繼承你所配置的屬性,但是如果你想針對特定的鄰居生效那你就直接再用neighbor的方式。具體還有跟據情況決定。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章