在BGP中有标准community属性和拓展community属性,拓展community属性在MP-BGP中引入,指RT与SOO。标准community属性在运行商的网络中用于区分用户路由,与路由标记(tag)有异曲同工的功能。

下面的这个实验简单演示一下community的使用。

拓扑:

 

BGP的公认必尊 bgp的community_BGP的公认必尊

说明:

1.              R1,R2属于运营商网络AS12,R3,R4,R5都属于客户网络,其中R3,R4是两个公司的分部,他们之间建立通信。

2.              R2通过OSPF 23获取客户R3的路由,R1分别通过OSPF14和OSPF15这两个进程获取R4,R5的路由。

3.              R1,R2使用loopback 0建立BGP peer,通过静态路由实现TCP连接。


 

配置:

1.  完成基础配置实现IGP通信

R1#sh ip int brie
Interface                  IP-Address      OK? Method Status                Protocol
Serial0/0                  12.1.1.1        YES manual up                    up      
Serial0/2                  14.1.1.1        YES manual up                    up      
Serial0/3                  15.1.1.1        YES manual up                    up      
Loopback0                 1.1.1.1         YES manual up                   up      
R1#sh run | b router ospf  
router ospf 14
 router-id 14.1.1.1
 log-adjacency-changes
network 14.1.1.1 0.0.0.0 area 0
!
router ospf 15
 router-id 15.1.1.1
 log-adjacency-changes
 network 15.1.1.1 0.0.0.0 area 0
!
ip route 2.2.2.2 255.255.255.255 Serial0/0 12.1.1.2

 
R2:
R2#sh ip int brie
Interface                  IP-Address      OK? Method Status                Protocol
Serial0/0                  12.1.1.2        YES manual up                    up      
Serial0/1                  23.1.1.2        YES manual up                    up      
Serial0/2                  unassigned      YES unset  administratively down down    
Serial0/3                  unassigned      YES unset  administratively down down    
Loopback0                  2.2.2.2         YES manual up                    up      
R2#sh run | b router ospf 
router ospf 23
 router-id 23.1.1.2
 log-adjacency-changes
 network 23.1.1.2 0.0.0.0 area 0
!
ip route 1.1.1.1 255.255.255.255 Serial0/0 12.1.1.1

 
R3:
R3#sh ip int brie
Interface                  IP-Address      OK? Method Status                Protocol
Serial0/1                  23.1.1.3        YES manual up                    up      
Serial0/2                  34.1.1.3        YES manual up                    down    
Loopback0                  3.3.3.3         YES manual up                    up      
R3#sh run | b router ospf 
router ospf 23
 router-id 3.3.3.3
 log-adjacency-changes
 passive-interface Loopback0
 network 3.3.3.3 0.0.0.0 area 0
 network 23.1.1.3 0.0.0.0 area 0

 
R4,R5配置略

 
2.  完成BGP配置
R1:
router bgp 12
 no synchronization
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 12
 neighbor 2.2.2.2 update-source Loopback0
 no auto-summary

 
R2:
router bgp 12
 no synchronization
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 12
 neighbor 1.1.1.1 update-source Loopback0
no auto-summary

 
3.  配置community列表,建立route-map
我们需要分别把OSPF23和OSPF14重发布进BGP12,在重发布的时候应用route-map打上community属性。
首先我们使用启用community的新版格式,cisco IOS默认的格式不好用。使用下面的命令启用。在R2,R3全局模式下启用。
ip bgp-community new-format

 
         R1:
R1(config)#route-map set-community-ospf14 
R1(config-route-map)#set community 12:14
R1(config-route-map)#exi

 
R2(config)#route-map set-community-ospf23
R2(config-route-map)#set community 12:23
R2(config-route-map)#exi
4.  将IGP重发布进BGP       
将IGP重发布进如BGP,结合前面步骤中定义的route-map。
R1(config)#router b 12
R1(config-router)#redis ospf 14 route-map set-community-ospf14

 
 
R2(config)#router b 12
R2(config-router)#redis ospf 23 route-map set-community-ospf23

 

5.  将BGP重发布进IGP

将BGP重发布进IGP是不推荐的,如果非要如此的话一定要做好过滤。本实验其实就是对这种情况做的一种过滤方法。默认情况下BGP不可以 重发布进IGP,我们首先开启重发布功能,然后定义community-list 用route-map调用来进行过滤。

R1:
ip community-list 10 permit 12:23
route-map match-community-ospf23 permit 10
match community 10

 
router ospf 14
redistribute bgp 12 subnets route-map match-community-ospf23

 
R2:
ip community-list 10 permit 12:14
route-map match-community-ospf14 permit 10
match community 10

 
router ospf 23
redistribute bgp 12 subnets route-map match-community-ospf14
6.最后,还有一个重要的小细节不能忘:想peer传递community属性
R1:
Router b 12
neighbor 2.2.2.2 send-community

 
R2:
Router b 12
neighbor 1.1.1.1 send-community
7.检查
R1#sh ip bgp community 12:14
BGP table version is 17, local router ID is 1.1.1.1
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
*> 4.4.4.4/32       14.1.1.4                65         32768 ?
*> 14.1.1.0/24      0.0.0.0                  0         32768 ?
R1#sh ip b community 12:23
BGP table version is 17, local router ID is 1.1.1.1
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
*>i3.3.3.3/32       23.1.1.3                65    100      0 ?
*>i23.1.1.0/24      2.2.2.2                  0    100      0 ?
 
R4#sh ip route ospf 
     3.0.0.0/32 is subnetted, 1 subnets
O E2    3.3.3.3 [110/1] via 14.1.1.1, 00:15:56, Serial0/0
     23.0.0.0/24 is subnetted, 1 subnets
O E2    23.1.1.0 [110/1] via 14.1.1.1, 00:15:56, Serial0/0

 

总结:其实这也是一种对等模型的×××,因为他符合对等模型的定义,运营商了解客户的路由,不同客户之间实现了路由的分离。本实验只演示了一对客户网络,所以还不能够很明显的观察到×××的特点,如果使用多组的客户对等起来的话就比较容易看出来了。但是,这种模型带来的问题就是管理开销比较大,拓展性不高。MPLS ×××是一个很好的解决方案。

这个实验主要就是简单演示下community的使用,需要注意一些小细节,当初我就在上面搞了好半天才做成功。好,到此结束!


转载于:https://blog.51cto.com/edges/400679