BGP路由属性

BGP路由属性

一组描述BGP路由特性的参数,在配置路由策略时被广泛使用。对于企业 和运营商所关心的问题,如:如何过滤某些BGP路由?如何影响BGP的选路?通过使用 BGP丰富的路由属性,就可以得到解决。

画板

属性分类 备注
公认必遵
well-known mandatory
所有BGP路由器都可以识别
且必须存在于Update消息中
公认任意
well-known discretionary
所有BGP路由器都可以识别
但不要求必须存在于Update消息中
可选过渡
optional transitive
不能被所有BGP路由器识别
如果无法识别,可以传递给邻居
可选非过渡
optional non-transitive
不能被所有BGP路由器识别
如果无法识别,则丢弃该属性
属性备注
PrefVal私有属性。
定义本地路由的优先级,本地有效,
不传播给邻居。
越大越优先。
Origin起源属性。
定义路由信息的来源,标记一条路由
是怎样成为BGP路由的。
AS_PATHAS路径属性。
是路由经过的AS的序列,即列出此路
由在传递过程中经过了哪些AS。可以
防止路由环路,并用于路由的过滤和
选择。
Next Hop下一跳属性。
MED 当某个AS有多个入口时,可以用MED
属性来帮助其外部的AS选择一个较好
的入口路径。
越小越优先。
Local-Preference本地优先级属性。
用于在AS内优选到达某一目的地的路
由。反映了BGP Speaker对每条BGP
路由的偏好程度。
越大越优。
Community团队属性。
标识了一组具有相同特征的路由信
息,与它所在AS无关。

PrefVal:优选值,越小越优先

Origin:起源,BGP路由的生成方式

代码 类型
i=IGP通过network宣告的路由
e=EGP通过EGP(已淘汰)学习到
?=incomplete通过import引入
优先级:i>e>?

AS PATH:AS路径,BGP路由在传输的路径中所经历的AS的列表

• EBGP传递时更新(加入自己的AS号码)

• 丢弃AS_PATH属性中包含本AS Number的路由(防止AS间环路)

• AS数量越少越优先

Next Hop:下一跳=更新源

Local-Preference:本地优先级

• 只传播给IBGP邻居(本地)

• 越大越优先,默认=100

• 常用于控制流量怎样流出AS(出站路由)

MED:Multi-Exit-DISC,相当于IGP的度量值

• 区别到达同一邻居AS的多条入口链路

• 越小越优先

• 仅在相邻两个AS之间传递,收到此属性的AS不会再通告给任何其他第三方AS

• 常用于控制流量怎样进入本AS(入站路由)

缺省情况下,不允许比较来自不同AS邻居的路由信息的MED值,除非能够确认不同

的AS采用了同样的IGP和路由选择方式,则可以使用命令:

命令 备注
compare-different-as-med比较不同AS邻居的MED值

BGP路由选路

BGP路由选路原则:BGP不像IGP,本身并没有路由算法,而是结合丰富的属性进行选路。

Q:

A:

如果比较到第九条全部相同,则为等价路由,可以负载分担(默认关闭,且

AS_PATH必须一致)

BGP路由控制:BGP可以结合几乎所有的策略工具,并利用BGP路径属性,来影响BGP的选路。

命令备注
peer 2.2.2.2 preferred-value 100配置优选值,默认0
default local-preference 200配置本地优先级,默认100
default med 100配置MED,默认0
peer 2.2.2.2 allow-as-loop 3配置AS编号重复次数

#
acl number 2000
 rule 5 permit source 192.168.1.0 0.0.0.255
#
bgp 200
 peer 10.1.1.1 as-number 100
 peer 3.3.3.3 as-number 200
#
ipv4-family unicast
 undo synchronization
 peer 10.1.1.1 enable
 peer 10.1.1.1 route-policy test1 import
#
route-policy test1 permit node 10
 if-match acl 2000
 apply local-preference 2000
route-policy testl permit node 20
 apply local-preference 1000
 #
#
acl number 2000
 rule 5 permit source 192.168.2.0 0.0.0.255
#
bgp 200
 peer 10.4.4.1 as-number 100
 peer 3.3.3.3 as-number 200
#
ipv4-family unicast
 undo synchronization
 peer 10.4.4.1 enable
 peer 10.4.4.1 route-policy test1 import
#
route-policy test1 permit node 10
 if-match acl 2000
 apply local-preference 2000
route-policy test1 permit node 20
 apply local-preference 1000
 #

bgp 100
 peer 10.1.1.2 as-number 200
 peer 5.5.5.5 as-number 100
#
ipv4-family unicast
 undo synchronization
 peer10.1.1.2 enable
 peer 10.1.1.2 route-policy test1 export
 peer5.5.5.5 enable
#
route-policy test1 permit node 10
 if-match ip-prefix 1
 apply cost 2800
route-policy test1 permit node 20
 apply cost 1000
#
ip ip-prefix 1 index 10 permit 192.168.3.0 24 greater-equal 24 less-equal 24
#
#
bgp 100
 peer 10.4.4.2 as-number 200
 peer 5.5.5.5 as-number 100
#
ipv4-family unicast
 undo synchronization
 peer 10.4.4.2 enable
 peer 10.4.4.2 route-policy test1 export
 peer 5.5.5.5 enable
#
route-policy test1 permit node 10
 if-match ip-prefix 1
 apply cost 2000
route-policy test1 permit node 20
 apply cost 1000
#
ip ip-prefix 1 index 10 permit 192.168.1.0 24 greater-equal 24 less-equal 24
#

BGP路由过滤

命令 备注
filter-policy 2000 export/import对宣告或接收的路由过滤
peer 2.2.2.2 filter-policy 2000 export/import
peer 2.2.2.2 as-path-filter xx export/import
peer 2.2.2.2 ip-prefix xx export/import
peer 2.2.2.2 route-policy xx export/import
以上如果同时配置,根据表格顺序进行过滤

AS-Path-Filter

通过正则表达式对AS信息进行过滤

命令 备注
ip as-path-filter xx deny 123$过滤始发123的路由
ip as-path-filter xx permit .*允许其他所有路由

Community:团体属性

标识具有相同特征的BGP路由,使路由策略的应用更加灵活,降低维护管理的难度。

公认团体属性:

团体属性名称 备注
Internet
0(0x00000000)
向任何BGP邻居宣告
No_Advertise
4294967042(0xFFFFFF02)
不向任何BGP邻居宣告
No_Export
4294967041(0xFFFFFF01)
不向EBGP邻居宣告
但可以向联盟内的EBGP邻居宣告
No_Export_Subconfed
4294967043(0xFFFFFF03)
不向任何EBGP邻居宣告
包括联盟内的EBGP邻居

私有团体属性

命令备注
peer x.x.x.x advertise-community配置允许邻居发送团体属性给邻居
ip community-filter 1 permit创建团体属性过滤器
display bgp routing-table community查看带有团体属性的路由

bgp 10
 peer 10.4.4.1 as-number 100
 peer 10.1.1.2 as-number 200
#
ipv4-family unicast
 undo synchronization
 peer 10.4.4.1 enable
 peer 10.1.1.2 enable
 peer 10.1.1.2 route-policy set community export
 peer 10.1.1.2 advertise-community
#
route-policy set_community permit node 10
apply community 100:1
bgp 100
 peer 10.4.4.2 as-number 100
 peer 10.3.3.1 as-number 300
#
ipv4-family unicast
 undo synchronization
 peer 10.4.4.2 enable
 peer 10.3.3.1 enable
 peer 10.3.3.1 route-policy set_community export
 peer 10.3.3.1 advertise-community
#
route-policy set community permit node 10
 apply community 100:2
bgp 300
 peer 10.2.2.1 as-number 200
 peer 10.3.3.2 as-number 300
#
ipv4-family unicast
 undo synchronization
 peer 10.2.2.1 enable
 peer 10.2.2.1 route-policy set_local pref import
 peer 10.2.2.1 advertise-community
 peer 10.3.3.2 enable
 peer 10.3.3.2 route-policy set local pref import
 peer 10.3.3.2 advertise-community
#
route-policy set local pref permit node 10
 if-match community-filer 1
 apply local-preference 200
Route-policy set local pref permit node 20
 if-match community-filter 2
 apply local-preference 50
#
 ip community-filter 1 permit  100:1
 ip community-filter 2 permit  100:2

查看团体属性:

BGP复位操作

命令备注
reset bgp all复位所有的BGP连接
reset bgp as-number复制与指定AS间的BGP连接
reset bgpx.x.x.x复位与指定邻居的BGP连接
reset bgp internal复位所有IBGP连接
reset bgp external复位所有EBGP连接

BGP负载负担

命令备注
maximum load-balancing 2配置最多支持的负载数量

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值