ADDRESS-FAMILY
en
conf t
# 設定bgp process id
router bgp 10
# 設定BGP的RID,通常指定loopback ip
bgp router-id 10.10.10.10
# 設定鄰居是誰
neighbor 192.168.1.1 remote-as 10
neighbor 192.168.2.1 remote-as 20
# BGP走哪一個協議
address-family ipv4 unicast
# 設定鄰居啟用
neighbor 192.168.1.1 activate
neighbor 192.168.2.1 activate
# 本機有哪一些網段要參與BGP
network 10.10.10.10 mask 255.255.255.255
network 20.20.20.20 mask 255.255.255.255
end
wr
# 檢查bgp路由狀態
show ip bgp
# 檢查鄰居狀態
show ip bgp summary
# 檢查路由表
show ip route [bgp]
LEGACY-IPv4
en
conf t
router bgp 10
bgp router-id 10.10.10.10
neighbor 192.168.1.1 remote-as 10
neightbor 192.168.2.1 remote-as 20
network 10.10.10.10 mask 255.255.255.255
network 20.20.20.20 mask 255.255.255.255
end
wr
The priority of BGP route selection
順序 屬性 範圍 / 規則 說明
---- -------------------------------- ------------------------------------------ ------------------------------------------------------
1 Weight 0 ~ 65535,越大越優先 Cisco 專屬,本機屬性,不會傳遞
2 Local Preference 0 ~ 4,294,967,295,越大越優先 AS 內有效,預設 100,影響整個 AS 出口路徑
3 Locally Originated N/A 本機宣告(network / aggregate / redistribute)優先
4 AS_PATH 越短越優先 經過的 AS 少,通常更穩定
5 Origin Type i > e > ? i: IGP,e: 舊 EGP,?: Redistribute
6 MED (Multi-Exit Discriminator) 0 ~ 4,294,967,295,越小越優先 只比較同 AS 來源,影響對方選擇進站路徑
7 eBGP over iBGP eBGP 優先 偏好外部路徑(Hot Potato Routing)
8 Lowest IGP metric to next-hop 越小越優先 比較 IGP 成本(非 AD),選擇最近出口
9 Oldest Path 最先建立的路徑優先 防止相同屬性路由 flapping,穩定性考量
10 Router ID (RID) 越小越優先 如果仍平手,再比 Router ID
11 Lowest Neighbor IP 越小越優先 所有屬性相同時,最終平手決定