江遇.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_PATH AS路径属性。 是路由经过的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编号重复次数

plain 复制代码
#
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
 #
plain 复制代码
#
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
 #
plain 复制代码
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
#
plain 复制代码
#
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 查看带有团体属性的路由
plain 复制代码
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
plain 复制代码
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
plain 复制代码
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 配置最多支持的负载数量
相关推荐
anddddoooo2 小时前
域内证书维权
服务器·网络·网络协议·安全·网络安全·https·ssl
Long._.L2 小时前
OpenSSL实验
网络·密码学
Dyan_csdn2 小时前
【Python项目】基于Python的Web漏洞挖掘系统
网络·python·安全·web安全
okok__TXF3 小时前
Rpc导读
网络·网络协议·rpc
&向上4 小时前
RK3588配置成为路由器
网络·智能路由器·rk3588
猫猫的小茶馆4 小时前
【网络编程】UDP协议
linux·服务器·网络·网络协议·ubuntu·udp
十月ooOO5 小时前
小米AX3000T 路由器如何开启 SSH 安装 OpenWRT 系统,不需要降级 v1.0.91 (2025)
网络·ssh·路由器·openwrt
SKYDROID云卓小助手5 小时前
无人设备遥控器之如何分享数传篇
网络·人工智能·算法·计算机视觉·电脑
r_martian6 小时前
RPC:分布式系统的通信桥梁
网络·网络协议·rpc