<Community>主要用来控制路由的传播范围

社团属性,也叫共同体属性,是可选传递属性 

 ·“可选”:意味着并不是所有的路由器都能识别这个社团属性。

·“传递”:意味着路由器即使不能识别这个属性,也能将这条路由继续传递下去。
·社团属性类似于tag标记,它允许路由器能够使用一个指示符来标记路由,并且允许其它路由器根据这个标记来控制路由的传播范围,或者对含有标记的路由做一些处理。一条路由可以设置多个社团属性,也就是说允许同时打上多个标记

·还可以利用社团属性实现一些扩展的功能。比如在MPLS-×××中的RT属性。

要去:

1.证明团体属性的区别及其传播范围

2.联盟的应用

3.反射器的应用

R1配置

interface Loopback0
 ip address 1.1.1.1 255.255.255.0
interface Loopback1
 ip address 1.1.2.1 255.255.255.0
interface Loopback2
 ip address 1.1.3.1 255.255.255.0
interface Loopback3
 ip address 1.1.4.1 255.255.255.0
interface Serial0/0
 ip address 12.1.1.1 255.255.255.0
 serial restart-delay 0
router ospf 10
 router-id 1.1.1.1
 log-adjacency-changes
 network 1.1.1.0 0.0.0.255 area 0
 network 1.1.2.0 0.0.0.255 area 0
 network 1.1.3.0 0.0.0.255 area 0
 network 1.1.4.0 0.0.0.255 area 0
 network 12.1.1.0 0.0.0.255 area 0
!router bgp 65535
 no synchronization
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 bgp confederation identifier 1
 network 1.1.1.0 mask 255.255.255.0
 network 1.1.2.0 mask 255.255.255.0
 network 1.1.3.0 mask 255.255.255.0
 network 1.1.4.0 mask 255.255.255.0
 neighbor 2.2.2.2 remote-as 65535
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 2.2.2.2 next-hop-self
 neighbor 2.2.2.2 send-community
 neighbor 2.2.2.2 route-map liang out
 no auto-summary
ip bgp-community new-format
access-list 10 permit 1.1.1.0
access-list 20 permit 1.1.2.0
access-list 30 permit 1.1.3.0
access-list 40 permit 1.1.4.0
route-map liang permit 10
 match ip address 10
 set community no-advertise
route-map liang permit 20
 match ip address 20
 set community no-export
route-map liang permit 30
 match ip address 30
set community local-AS
route-map liang permit 40
 match ip address 40
 set community internet

R2的配置

interface Loopback0
 ip address 2.2.2.2 255.255.255.0
interface Serial0/0
 ip address 12.1.1.2 255.255.255.0
 serial restart-delay 0
interface Serial0/1
 ip address 23.1.1.2 255.255.255.0
 serial restart-delay 0
interface Serial0/2
 ip address 24.1.1.2 255.255.255.0
 serial restart-delay 0
router ospf 10
 router-id 2.2.2.2
 log-adjacency-changes
 network 2.2.2.0 0.0.0.255 area 0
 network 12.1.1.0 0.0.0.255 area 0
 network 23.1.1.0 0.0.0.255 area 0
router bgp 65535
 no synchronization
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 bgp confederation identifier 1
 bgp confederation peers 65534
 neighbor 1.1.1.1 remote-as 65535
 neighbor 1.1.1.1 update-source Loopback0
 neighbor 3.3.3.3 remote-as 65535
 neighbor 3.3.3.3 update-source Loopback0
 neighbor 3.3.3.3 route-reflector-client
 neighbor 3.3.3.3 next-hop-self
 neighbor 3.3.3.3 send-community
 neighbor 4.4.4.4 remote-as 65534
 neighbor 4.4.4.4 send-community
 neighbor 24.1.1.4 remote-as 65534
 neighbor 24.1.1.4 ebgp-multihop 255
 neighbor 24.1.1.4 next-hop-self
 neighbor 24.1.1.4 send-community
 no auto-summary
ip bgp-community new-format

R3的配置

interface Loopback0
 ip address 3.3.3.3 255.255.255.0
interface Serial0/1
 ip address 23.1.1.3 255.255.255.0
 serial restart-delay 0
router ospf 10
 router-id 3.3.3.3
 log-adjacency-changes
 network 3.3.3.0 0.0.0.255 area 0
 network 23.1.1.0 0.0.0.255 area 0
router bgp 65535
 no synchronization
 bgp router-id 3.3.3.3
 bgp log-neighbor-changes
 bgp confederation identifier 1
 neighbor 2.2.2.2 remote-as 65535
 neighbor 2.2.2.2 update-source Loopback0
 no auto-summary

R4的配置


interface Loopback0
 ip address 4.4.4.4 255.255.255.0
interface Serial0/2
 ip address 24.1.1.4 255.255.255.0
 serial restart-delay 0
interface Serial0/3
 ip address 45.1.1.4 255.255.255.0
 serial restart-delay 0
router bgp 65534
 no synchronization
 bgp router-id 4.4.4.4
 bgp log-neighbor-changes
 bgp confederation identifier 1
 bgp confederation peers 65535
 neighbor 24.1.1.2 remote-as 65535
 neighbor 24.1.1.2 ebgp-multihop 255
 neighbor 45.1.1.5 remote-as 2
 neighbor 45.1.1.5 ebgp-multihop 255
 neighbor 45.1.1.5 send-community
 no auto-summary

R5的配置


interface Serial0/3
 ip address 45.1.1.5 255.255.255.0
 serial restart-delay 0
router bgp 2
 no synchronization
 bgp router-id 5.5.5.5
 bgp log-neighbor-changes
 neighbor 45.1.1.4 remote-as 1
 no auto-summary

我们是在R1上起四个路由条目并通过route-map抓住打上四个不同的团体属性值

·社团属性分以下两种:
  1、well-known communities 公认团体
  2、Private communities  私有团体

·社团属性中已经预定义好的三类well-known属性:
   no-advertise:携带此属性的路由不会通告给任何BGP邻居。也就是说只传达给一个邻居
   no-export:  携带此属性的路由不会传出本AS外,只会传给IBGP。(联邦中的小AS会传递)。
   local-AS:   携带此属性的路由不会传出小AS。

internat     携带此属性的可以任意传播不受AS的限制

R2#show ip bgp  四条都有
BGP table version is 7, local router ID is 2.2.2.2
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
*>i1.1.1.0/24       1.1.1.1                  0    100      0 i
*>i1.1.2.0/24       1.1.1.1                  0    100      0 i
*>i1.1.3.0/24       1.1.1.1                  0    100      0 i
*>i1.1.4.0/24       1.1.1.1                  0    100      0 i

R3# show ip bgp 因为1.1.1.0打上的是no-ad的属性只会传一跳所以R3上收不到
BGP table version is 8, local router ID is 3.3.3.3
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
*>i1.1.2.0/24       1.1.1.1                  0    100      0 i
*>i1.1.3.0/24       1.1.1.1                  0    100      0 i
*>i1.1.4.0/24       1.1.1.1                  0    100      0 i

R4#show ip bgp 1.1.3.0 打上的是local属性不会传出小AS(联盟)所以R4属于另一个联盟收不到
BGP table version is 15, 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
*> 1.1.2.0/24       24.1.1.2                 0    100      0 (65535) i
*> 1.1.4.0/24       24.1.1.2                 0    100      0 (65535) i

R5# show ip bgp
BGP table version is 25, 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
*> 1.1.4.0/24       45.1.1.4                               0 1 i

在R5上只收到一条internet属性的条目  no-export 会在大AS内传播但不会给公有EBGP传播