VyOS 上的 BGP 介紹
本課程將說明如何在 VyOS 1.4.x/1.5 rolling release 上設定 BGP(Border Gateway Protocol)。BGP 是大型網路、ISP 與多供應商互聯的標準動態路由協定。
1. BGP 基礎觀念
- AS (Autonomous System):自治系統。
- iBGP vs eBGP:iBGP(內部)、eBGP(外部互聯)。
- Path Selection:最佳路徑選擇規則。
2. BGP 基本設定
set protocols bgp 65001 parameters router-id 1.1.1.1
set protocols bgp 65001 neighbor 2.2.2.2 remote-as 65002
set protocols bgp 65001 neighbor 2.2.2.2 address-family ipv4-unicast
set protocols bgp 65001 network 192.168.10.0/24
set protocols bgp 65001 network 10.10.10.0/24
- Route-map、prefix-list、AS-path:
set policy prefix-list PL-OUT rule 10 action permit prefix 192.168.10.0/24
set policy route-map RM-OUT rule 10 action permit
set policy route-map RM-OUT rule 10 match ip address prefix-list PL-OUT
set protocols bgp 65001 neighbor 2.2.2.2 route-map export RM-OUT
set protocols bgp 65001 neighbor 2.2.2.2 as-path-prepend '65001 65001'
3. BGP Communities、Route Reflector、IPv6
set protocols bgp 65001 neighbor 3.3.3.3 remote-as 65001
set protocols bgp 65001 neighbor 3.3.3.3 route-reflector-client
set protocols bgp 65001 neighbor 2.2.2.2 address-family ipv6-unicast
set protocols bgp 65001 neighbor 2.2.2.2 extended-nexthop
set protocols bgp 65001 neighbor 2.2.2.2 soft-reconfiguration inbound
4. 檢查 BGP 狀態
show ip bgp summary
show ip bgp
show ip bgp neighbors
5. 範例網路拓撲
+---------+ +---------+
| VyOS 1 |-----| VyOS 2 |
| AS65001| | AS65002|
+---------+ +---------+
6. 實作實驗:2 個 AS 的 BGP Peering
- 在 2 台不同 AS 的 VyOS 上設定 BGP。
- 設定 neighbor、route-map、prefix-list、as-path-prepend。
- 提交並儲存設定:
commit
save
- 檢查 BGP 狀態與路由。
show ip bgp summary
show ip bgp
7. 總結
你已學會在 VyOS 上設定 BGP,並可應用於大型、多供應商網路中的動態路由策略控制。