BGP的属性详解

BGP的属性

BGP的属性可分为4类

BGP共有11条属性:weight,origin,AS-Path,next-hop,local_pref,atomic_aggregate,Aggregator,community,MED,originator_id,cluster_list

公认必尊:

一定传,一定识别,一定遵守
属性(originAS_path,next_hop

公认可尊:

不一定传,一定识别,不一定遵守
local_prefatomic_aggregate,(比如local_pref一定能识别,可能有其他比local_pref更优先的选路原则时不遵守)

可选传递:

不一定传,不一定识别,都能传递
aggregatorcommunity(即使设置了,也可以传,也可以不传)

可选非传递:

不一定传,不一定识别,若不识别
不能识别的BGP路由器将丢弃,只能影响自己 MED weight originator_IDcluster_ID

1.Weight(权重值)

cisco私有属性,选路属性,可选非传递。当本路由器有多个到达目标路径时(无视邻居关系),选择weight值大的一方到达(默认为空,越大越好),weight值只影响本路由器,其他路由器不识别该属性会丢弃该属性,默认本路由产生的路由条目的weight值为32768,学习到的路由条目权重值为0

weight选路是适用的,但是有多个出口路由器的情况下weight就不太适用

修改方法

1.建邻时直接加上weight

R1(config)#router bgp 2 
R1(config-router)#Neighbor 10.1.34.3 weight 1

修改该邻居所有传递过来的路由weight为1,只能影响本路由器,不能影响其他路由器

2.route-map修改

R1(config)#ip prefix-list weight permit 10.5.5.5/32
R1(config)#route-map weight permit 10
R1(config-route-map)#match ip address prefix-list weight
R1(config-route-map)#set weight 1
R1(config-route-map)#exit
R1(config)#route-map weight permit 20 //空表不修改其他人
R1(config-route-map)#exit
R1(config)#router bgp 1
R1(config-router)#neighbor 10.3.3.3 route-map weight in 

方向:只针对于某一个路由器修改weight,只能用in方向

2.origin(起源属性)

选路属性,公认必尊,可以识别路由的起源,network宣告的路由起源标志i(0),重发布的路由起源标识为(3)?,EBGP给的路由起源为e(2),i>e>? i和?可以修改,e不能修改,默认传递过程中不修改

该属性可以用于选路,但是一般不用于选路

修改方法:

R1(config)#ip prefix-list a permit 10.5.5.5/32
R1(config)#route-map org permit 10
R1(config-route-map)#match ip address prefix-list 10
R1(config-route-map)#set origin igp/incomplete
R1(config-route-map)#exit
R1(config)#route-map permit 20
R1(config-route-map)#exit
R1(config)#router bgp 2
R1(config-router)#neighbor 10.2.2.2 route-map org in

方向:用in/out方向都行,适用于任何邻居之间

3.Next-hop(下一跳)

公认必尊,用于提供可达性
1.IBGP传递的next-hop不会被修改,为0时候会修改自己为更新源地址
2.EBGP传递的next-hop会被修改,修改为自己的更新源地址

选路:下一跳为0.0.0.0的优于其他路径

R1(config)#ip prefix-list next permit 10.1.1.1/32
R1(config)#route-map next permit 10
R1(config-route-map)#match ip address prefix-list a
R1(config-route-map)#set ip next-hop 1.1.1.1
R1(config)#route-map next permit 20
R1(config-route-map)#exit
R1(config)#router bgp 2
R1(config-router)#neighbor 10.1.24.2 rotue-map next in

方向:方向无要求in/out,适用于任何邻居之间

4.AS-path(经过的AS)

公认必尊,记录路由经过的AS路径(不包括自己),顺序是最近进过的AS排在后面,一个AS拒绝接收携带自己AS号的路由,可以用来防环,选路,越短越好

修改方法

R4(config)#ip prefix-list permit 10.1.1.1/32
R4(config)#route-map ap permit 10
R4(config-route-map)#match ip address prefix-list 10
R4(config-route-map)#set as-path prepend 2 3 4 
R4(config-route-map)#exit
R4(config)#route-map ap permit 20
R4(config-route-map)#exit
R4(config)#router bgp 2
R4(config-router)#neighbor 10.1.24.2 route-map ap in

方向:我们一般在选路中添加AS会重复添加自己已经经历过的AS,不会添加没有经历的AS,适用于任何邻居之间,in/out方向都行

打破防环

R4(config-router)#neighbor 1.1.1.1 allowas-in

允许含有自己AS号的路由进入本AS,本路由器使用

R4(config-router)#neighbor 1.1.1.1 as-override

把具有和其他AS相同AS号的路由放入这个AS,邻居路由器使用

5.Local-pref(本地优先级)

公认可遵,选路属性,越大越好,用于在两个或者两个以上AS出口的选择,只能在IBGP之间传递,不能再EBGP之间传递

local-pref默认为100

常用于当本地AS有多个出口路由器时,选择拥有Local_pref值大的作为出口路由器,也可以是一个到达一个网段有多个出口,选择Local_pref大的路径,影响本AS其他路由器,不会影响自己

修改方法:
1.修改路由器的默认Local_pref值,该路由器通告给IBGP邻居的路由都会携带修改后的Local_pref值

R3(config)#router bgp 1
R3(config-router)#bgp default local_preference 120

2.通过route-map修改Local_pref值

R3(config)#ip prefix-list local permit 10.4.4.4/32
R3(config)#route-map local permit 10
R3(config-route-map)#match ip address prefix-list 10
R3(config-route-map)#set local_preference 120
R3(config-route-map)#exit
R3(config)#route-map local permit 20
R3(config-route-map)#exit
R3(config)#router bgp 2
R3(config-router)#neighbor 10.1.24.2 route-map ap in

方向:EBGP邻居只能为in,IBGP邻居in/out都可以

6.MED(metric度量值)

可选非传递,选路属性,用于选路,一般用于AS有两个或者两个以上入口时,其他AS选择哪个入口进入本AS。MED只能用于两个AS之间的选路,可以在两个AS之间传递,超过两个AS该参数无效,可以打开多AS的MED比较

两AS之间,一般配合Local_pref使用

两个方向:in影响自己,out影响别人
默认为0

R3(config)#ip prefix-list med permit 10.4.4.4/32
R3(config)#route-map med permit 10
R3(config-route-map)#match ip address prefix-list 10
R3(config-route-map)#set metric 120
R3(config-route-map)#exit
R3(config)#route-map med permit 20
R3(config-route-map)#exit
R3(config)#router bgp 2
R3(config-router)#neighbor 10.1.24.2 route-map med in

R3(config-router)#bgp always-compare-med //开启比较不同AS的MED

一般用于影响对方AS(out方向),如果本AS(in方向)使用和Local_pref等同(MED不能在路由器上修改默认值)

7.Atomic-aggregate(汇总)

用来警告下游路由器路由聚合后产生的路由路径丢失
用汇总的路由器,产生一条新的路由条目,即汇总路由条目

R2(config)#router bgp 1
R2(config-router)#aggregate-address 10.0.0.0 255.0.0.0

aggregate-address 10.0.0.0 255.0.0.0
汇总明细都通告
aggregate-address 10.0.0.0 255.0.0.0 summary-only
只通告汇总
aggregate-address 10.0.0.0 255.0.0.0 supress-map
只通告明细,可以加route-map定义
aggregate-address 10.0.0.0 255.0.0.0 summary-only as-set
继承明细的AS-path破解环路
aggregate-address 10.0.0.0 255.0.0.0 advertise-map
通告某些属性可以加route-map可以让汇总后的路由,添加上某些属于明细的属性
aggregate-address 10.0.0.0 255.0.0.0 attribute-map
设置聚合后的属性,新添加的,与明细自身属性无关,可以加route-map定义

8.Aggregator(汇总者)

用来通告汇总路由的聚合路由器BGP_ID(cisco),方便寻找汇总者

9.community(社团属性)

团体属性,为了更好地标识BGP路由
有两种格式:
1.标准格式 数字
2.扩展形式 x:y
团体值不能设置在EBGP,传递可以在IBGP之间也可以在EBGP之间

设置
设置必须在IBGP之间可以用in/out

R2(config)#Ip prefix-list com permit 10.0.4.4/32
R2(config)#Route-map com permit 10
R2(config-route-map)#Match ip address prefix-list com
R2(config-route-map)#Set community 2:100
R2(config-route-map)#exit
R2(config)#Route-map com permit 20
R2(config-route-map)#exit

传递设置

R2(config)#Rotuer bgp 2
R2(config-rotuer)#Neighbor 10.1.24.2 route-map com out

R2(config-rout)#Neighbor 10.1.24.2 send-community standard/extended
此条命令必须写,不写不传递社团属性

匹配设置

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

开启扩展格式匹配,标准格式下2:100会显示为数字,开启扩展模式,可正常显示属性值

ip community-list expanded K permit 111
专门的community匹配工具用community-list匹配完成后route-map可直接调用

查看命令

R1#show ip bgp 10.1.1.1 //查看此条路由团体值
R1#show ip bgp community //查看所有团体值的路由
R1#show ip bgp community 111 //只查看团体值为111的路由

子属性
在这里插入图片描述
1.Internet默认属性,可以给任何bgp发送,不对携带团体值得路由做任何限制
2.no_export只能在一个AS传递,可以在联盟内传递,该属性就是限制携带团体值得路由传递给EBGP邻居,联盟的EBGP除外。
3.no_advertise不在IBGP,EBGP邻居之间传递,禁止传递给任何邻居
4.Local_AS不想任何EBGP邻居发送包,包括联盟内的EBPG邻居

10.Originator_ID

路由反射器使用,为32bit值,该值是本地路由发起者的RID值,如果路由器有发起者从属性上看到自己的RID,说明有环路,忽略

11.Cluster_list

路由反射器使用,当路由进过反射器簇ID的一个序号,标识自己经过哪些反射器,当反射器看到自己的簇ID说明有环路,忽略

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值