

📌 适用设备:华为 AR 路由器、CloudEngine 系列交换机、NE 系列路由器(VRP) ⭐ 适用人群:HCIA Datacom、HCIP Datacom、HCIE Datacom、企业网络工程师 💡 建议收藏:BGP 是企业双出口、运营商互联、MPLS VPN、数据中心网络中最核心的路由协议之一。
BGP(Border Gateway Protocol,边界网关协议)是互联网和大型企业网络中使用最广泛的路径矢量路由协议(Path Vector)。
BGP 主要应用于:
bgp 65001
router-id 1.1.1.1
peer 2.2.2.2 as-number 65002
display current-configuration | include bgp
display bgp peer
peer 2.2.2.2 connect-interface LoopBack0
peer 2.2.2.2 ebgp-max-hop 2
peer 2.2.2.2 password cipher Huawei@123
peer 2.2.2.2 enable
undo peer 2.2.2.2
network 192.168.10.0 255.255.255.0
network 1.1.1.1 255.255.255.255
import-route static
import-route ospf 1
import-route rip 1
acl number 3000
ip ip-prefix PREFIX permit 10.0.0.0 8
route-policy EXPORT permit node 10
if-match ip-prefix PREFIX
apply local-preference 200
apply cost 50
apply as-path 65001 additive
apply community 100:1
apply ip-address next-hop 3.3.3.3
apply preferred-value 200
peer 2.2.2.2 route-policy EXPORT export
peer 2.2.2.2 route-policy IMPORT import
peer 2.2.2.2 ip-prefix PREFIX export
peer 2.2.2.2 filter-policy 3000 export
peer 2.2.2.2 next-hop-local
display bgp peer
display bgp routing-table
display bgp routing-table best-route
display bgp routing-table 10.10.10.0
display bgp statistics
display tcp status
display ip interface brief
display ip routing-table
ping 2.2.2.2
tracert 2.2.2.2
reset bgp peer 2.2.2.2
refresh bgp all export
display logbuffer
debugging bgp all
undo debugging all
display current-configuration
save
display version
display cpu-usage
display memory
场景 | 配置重点 |
|---|---|
企业双运营商出口 | 配置 EBGP、多出口选路、默认路由引入 |
数据中心互联 | IBGP + OSPF/IS-IS,Loopback 建邻 |
MPLS L3VPN | MP-BGP 发布 VPNv4 路由 |
IDC 多宿主接入 | Local Preference、AS-Path、MED 调优 |
云专线(AWS/Azure/阿里云) | EBGP 建邻、路由发布与过滤 |
双活数据中心 | Community、路由策略、负载分担 |
广域网互联 | Route-Policy 精确控制路由传播 |
多出口互联网 | Local Preference 控制主备出口 |
路由汇总 | Aggregate 路由,减少路由表规模 |
防止路由泄露 | Prefix-List + Route-Policy + Community |
序号 | 易错点 | 问题现象 | 解决方法 |
|---|---|---|---|
1 | AS 号配置错误 | 邻居始终建立失败(Idle/Active) | 检查本地 AS 与对端 AS 是否正确配置。 |
2 | 邻居 IP 不可达 | BGP 长时间停留在 Active 状态 | 确认底层路由可达,使用 ping、tracert 验证连通性。 |
3 | 忘记配置 connect-interface | Loopback 建邻失败 | 使用 Loopback 建邻时,双方均需指定 connect-interface LoopBack0。 |
4 | 未配置 ebgp-max-hop | 非直连 EBGP 建邻失败 | 当 EBGP 非直连时,增加 TTL,例如 ebgp-max-hop 2。 |
5 | network 命令对应路由不存在 | 路由未发布 | BGP 仅发布已存在于路由表中的前缀,需确保目标路由已安装。 |
6 | Route-Policy 配置错误 | 路由未学习或未发布 | 检查策略匹配条件和 permit/deny 是否符合预期。 |
7 | Next-Hop 不可达 | 收到路由但无法转发业务 | 确保下一跳地址可达,必要时配置 next-hop-local。 |
8 | Local Preference、MED 设置不当 | 选路结果异常 | 理解各路径属性的优先级,避免策略冲突。 |
9 | 忽略软重置(Soft Reset) | 修改策略后路由未更新 | 使用 Route Refresh 或 Soft Reset,使策略即时生效。 |
10 | 忽略路由过滤 | 路由泄露或接收异常路由 | 使用 Prefix-List、ACL、Route-Policy 控制路由发布与接收。 |