您的位置:首页 > 移动开发 > Unity3D

BGP的Community属性大揭秘

2020-03-18 19:07 525 查看

TOBGP的Community属性大揭秘

  1. 什么是Community属性

首先community是一个任选可透明传送属性,它可以用于简化策略的执行。其次Community属性可以让一组目的网段享用某些相同的路由特性,但这些目的网段不必要求处于同一AS。它可以用来控制BGP信息所经过的路由器怎么对待这条BGP信息。

community属性可以用一组4个8位组的数值表示。格式为:AA:NN,前两个8位组表示自治系统,后2个8位组表示出地管理目的而定义的标识符。以下是定义的一些团体属性,即公共的community属性:

(1)internet :所有路由在默认情况下都属于该团体

(2)No_export: 表示携带该值的路由不能公布给EBGP邻居,如果配置了BGP联盟,则不能将该路由宣告到联盟之外,携带该值的路由可以公布给联盟内的其它子自治系统但不能在构成联盟的AS以外进行公布

(3)no_advertise:如果接收到的路由携带该数值,那就谁也不宣告,包括EBGP或IBGP对等体。

(4)local-as :带有该团体属性的路由条目只在本as内传播,不能宣告给ebgp对等体。

大家要注意NO_export和local-as的区别,如果没有配置联盟,两者实现的效果都是一样的,即都不可以传输本AS,但如果配置了联盟,NO_EXPOR属性还可以传给联盟内的其他子AS,而local-as则不可以

2、案例研究

如上图在r1上宣告10.1.1.0-10.1.4.0这4条路由,要求如下

r2上可以看到10.1.1.0-10.1.4.0这4条路由

R3上可以看到10.1.2.0-10.1.4.0这3条路由

R4上可以看到10.1.3.0-10.1.4.0这2条路由

R5上可以看到10.1.4.0这1条路由

当然实现这种效果的方法有很多,但是请你想一想如果我们使用Community属性应该怎么实现?

建议如下:

在R1上使用前缀列表匹配路由,分别对不同的路由设置不同的community属性

针对10.1.1.0设置no_advertise属性

针对10.1.2.0设置local-AS属性

针对10.1.3.0设置No_export属性

针对10.1.3.0设置none属性

具体配置如下:

R1的配置

(1)首先设置前缀列表匹配路由

ip prefix-list 1 seq 5 permit 10.1.1.0/24

ip prefix-list 2 seq 5 permit 10.1.2.0/24

ip prefix-list 3 seq 5 permit 10.1.3.0/24

ip prefix-list 4 seq 5 permit 10.1.4.0/24

备注:使用前缀列表可以做到精确匹配路由

(2)使用route-map做路由策略

route-map comm-test permit 10

match ip address prefix-list 1

set community no-advertise

route-map comm-test permit 20

match ip address prefix-list 2

set community local-AS

route-map comm-test permit 30

match ip address prefix-list 3

set community no-export

route-map comm-test permit 40

match ip address prefix-list 4

set community none

(3)BGP的配置

router bgp 100

no synchronization

bgp router-id 1.1.1.1

network 10.1.1.0 mask 255.255.255.0

network 10.1.2.0 mask 255.255.255.0

network 10.1.3.0 mask 255.255.255.0

network 10.1.4.0 mask 255.255.255.0

neighbor 192.1.12.2 remote-as 234

neighbor 192.1.12.2 send-community

neighbor 192.1.12.2 route-map comm-test out //调用route-map

no auto-summary

备注:切记不要忘记向邻居发送community属性,使用以下命令

neighbor 192.1.12.2 send-community

R2的配置

(1)BGP的配置

router bgp 64512

no synchronization

bgp router-id 2.2.2.2

bgp confederation identifier 234

neighbor 3.3.3.3 remote-as 64512

neighbor 3.3.3.3 update-source Loopback0

neighbor 3.3.3.3 next-hop-self

neighbor 3.3.3.3 send-community

neighbor 192.1.12.1 remote-as 100

no auto-summary

(2)在R2上查看bgp表

r2#sh ip bgp

BGP table version is 8, local router ID is 2.2.2.2

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal

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

Network Next Hop Metric LocPrf Weight Path

*> 10.1.1.0/24 192.1.12.1 0 0 100 i

*> 10.1.2.0/24 192.1.12.1 0 0 100 i

*> 10.1.3.0/24 192.1.12.1 0 0 100 i

*> 10.1.4.0/24 192.1.12.1 0 0 100 i

以上可以看到4条路由都学习到了,再查看某一条具体的路由条目,查看其详细属性

r2#sh ip bgp 10.1.1.0

BGP routing table entry for 10.1.1.0/24, version 5

Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to any peer)

Not advertised to any peer

100

192.1.12.1 from 192.1.12.1 (1.1.1.1)

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

Community: no-advertise   //属性已传递

r2#sh ip bgp 10.1.2.0

BGP routing table entry for 10.1.2.0/24, version 8

Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised outside local AS)

Advertised to non peer-group peers:

3.3.3.3

100

192.1.12.1 from 192.1.12.1 (1.1.1.1)

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

Community: local-AS    //属性已传递

…………

R3的配置

(1)BGP的配置

router bgp 64512

no synchronization

bgp router-id 3.3.3.3

bgp confederation identifier 234

bgp confederation peers 64514

neighbor 2.2.2.2 remote-as 64512

neighbor 2.2.2.2 next-hop-self

neighbor 4.4.4.4 remote-as 64514

neighbor 4.4.4.4 ebgp-multihop 255

neighbor 4.4.4.4 update-source Loopback0

neighbor 4.4.4.4 send-community

no auto-summary

(2)在R3上查看bgp表,可以看到没有学习到 10.1.1.0/24的路由

r3#sh ip bgp

BGP table version is 7, local router ID is 3.3.3.3

Network Next Hop Metric LocPrf Weight Path

*>i10.1.2.0/24 2.2.2.2 0 100 0 100 i

*>i10.1.3.0/24 2.2.2.2 0 100 0 100 i

*>i10.1.4.0/24 2.2.2.2 0 100 0 100 i

R4的配置

(1)BGP的配置

router bgp 64514

no synchronization

bgp router-id 4.4.4.4

bgp confederation identifier 234

bgp confederation peers 64512

neighbor 3.3.3.3 remote-as 64512

neighbor 3.3.3.3 ebgp-multihop 255

neighbor 3.3.3.3 update-source Loopback0

neighbor 192.1.45.5 remote-as 500

no auto-summary

(2)在R4上查看BGP表,可以看到10.1.2.0这条路由没有过来

r4#sh ip bgp

Network Next Hop Metric LocPrf Weight Path

*> 10.1.3.0/24 2.2.2.2 0 100 0 (64512) 100 i

*> 10.1.4.0/24 2.2.2.2 0 100 0 (64512) 100 i

查看10.1.3.0/24的详细信息

r4#sh ip bgp 10.1.3.0/24

BGP routing table entry for 10.1.3.0/24, version 2

Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to EBGP peer)

Not advertised to any peer

(64512) 100

2.2.2.2 (metric 2) from 3.3.3.3 (3.3.3.3)

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

Community: no-export  //携带该值的路由不能公布给EBGP邻居

R5的配置

(1)BGP的配置

router bgp 500

no synchronization

bgp router-id 5.5.5.5

bgp cluster-id 2886734593

bgp log-neighbor-changes

neighbor 192.1.45.4 remote-as 234

no auto-summary

r5#sh ip bgp

BGP table version is 4, 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

Network Next Hop Metric LocPrf Weight Path

*> 10.1.4.0/24 192.1.45.4 0 234 100 i

实验完成。

  • 点赞
  • 收藏
  • 分享
  • 文章举报
uyi60 发布了1 篇原创文章 · 获赞 0 · 访问量 44 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: