BGP基礎知識

一、BGP協議特性

圖片.png

二、BGP基本術語

圖片.png

三、鄰居狀態機制

圖片.png

圖解

圖片.png

四、路由屬性

圖片.png

五、選路原則

圖片.png

首先,路由的下一跳必須可達,然後BGP按照下面順序選路:
<1>prefer-value (越大越好)
<2>local-pref (越大越好)
<3>本地始發
<4>as-path  (越短越好)
<5>origin(i>e>?)
<6>med  (越小越好)
<7>ebgp>ibgp
<8>igp costfornext-hop  (越小越好)
<9>是否支持負載均衡(maximumload-balance)
<10>cluster-list (越短越好)
<11>originator-id (越小越好)
<12>router-id(越小越好)
<13>next-hop ip address#neighbor‘s ip address (越小越好)

圖片.png

六、BGP路由發佈策略
圖片.png

七、路由產生方式

圖片.png

八、反射器、聯邦

圖片.png

九、配置命令

bgp 1 #創建並啓動BGP
router-id 1.1.1.1 #配置router-id
peer 12.1.1.2 as-number 2 #指定BGP對等體及AS號
peer 12.1.1.2 connect-interface loop0 #使用自己的loopback0做爲更新源,和對方建立鄰居
peer 12.1.1.2 ebgp-max-hop 1 #配置允許同非直接相連的網絡上的鄰居建立EBGP連接
peer 3.3.3.3 next-hop-local #
peer 1.1.1.1 reflect-client #設置1.1.1.1位路由反射器的client
network 21.1.1.0 255.255.255.0 #將本地路由發佈到BGP路由表中(必須宣告自己真實存在的網絡)
import-route ospf 11 #引入其它路由協議的路由
undo synchronization #關閉同步,高版本IOS默認開啓

圖片.png

圖片.png

ip route 2.2.2.0 255.255.255.0 24.1.1.2  //先確保有去鄰居的路由

Cisco配置

router bgp 4
  no auto-summary   //關閉自動彙總
  no synchronization     //關閉同步,高版本IOS默認開啓
  bgp router-id 4.4.4.4
  neighbor 2.2.2.2 remote-as 123         //指定EBGP鄰居
  neighbor 2.2.2.2 update-source lo0     //指定自已的更新源
  neighbor 2.2.2.2 ebgp-multihop 2       //設置EBGP的多跳
  neighbor 3.3.3.3 next-hop-self    
  network 172.16.1.0 mask 255.255.255.0   //宣告網絡時要說明掩碼
  neighbor 3.3.3.3 soft-reconfiguration inbound  //開啓查看接收到的路由信息的功能
  neighbor 3.3.3.3 peer-group WOLF      //在鄰居上調用

各類顯示命令:
show ip bgp summary      //摘要的鄰居鄰居信息
show ip bgp 2.2.2.0/24   //顯示明細路由的詳細信息
show tcp brief           //可以看到是誰發起的TCP鏈接
show ip bgp neighbors    //詳細的鄰居信息
show ip bgp rib-failure  //可以看到提示有更高AD的路由
show ip bgp neighbors 2.2.2.2 advertised-routes  //看向這個鄰居發了哪些路由信息
show ip bgp neighbors 3.3.3.3 received-routes    //看這個鄰居給我發了哪些路由信息,必須在本路由器上用下面這條命令開啓
show ip bgp nei x.x.x.x advertised-router 查看向鄰居通告的路由器有哪些
show ip bgp nei x.x.x.x received-router 查看鄰居向本地通告的路由有哪些,前提開啓入站配置

clear ip bgp *         //來硬的,會DOWN掉鄰居關係
clear ip bgp nei xxxxx //具體清楚掉某一個鄰居
clear ip bgp * soft    //軟清,不會down掉鄰居關係
clear ip bgp * soft  in/out  //在in或out方向軟清,不會down掉鄰居關係


BGP路由不優的2個原因:
1、同步問題
2、下一跳是否可達  
BGP的下一跳機制
BGP是一個AS-by-AS的路由協議,而不是一個router-by-router的路由協議。
BGP路由的下一跳並不是指下一個路由器的IP地址,而是指到達下一個AS的IP地址。
所以,默認情況下,從EBGP鄰居學到的路由再向其它的IBGP鄰居傳遞的時候,下一跳不改變。


華爲配置

bgp 100  #啓動bgp指定as號
 router-id 1.1.1.1  #配置BGP的router-id
 peer 12.1.1.1 as-number 100 #創建BGP對等體
 peer 12.1.1.1 connet-interface lookback 0 #指定發送BGP報文的源接口,並可指定發起連接時使用的源地址

 peer 12.1.1.1 ebgp-max-hop 2 #指定建立EBGP連接允許的最大跳數。缺省情況下,EBGP連接允許的最大跳數爲1,即只能在物理直連鏈路上建立EBGP連接
 peer 12.1.1.1 next-hop-local #配置BGP設備向IBGP對等體(組)發佈路由時,把下一跳地址設爲自身的IP地址。 缺省情況下,BGP設備向IBGP對等體發佈路由時,不修改下一跳地址
 nexthop recursive-loolup router-policy #配置BGP按路由策略進行下一跳迭代。

 peer 12.1.1.1 next-hop-invariable #配置發佈引入的IGP路由時不改變該IGP路由的下一跳地址。缺省情況下,對等體在發佈所引入的IGP路由時會將下一跳地址改爲本地與對端連接的接口地址

 import-router protocol  #引入路由
 default-route imported  #允許BGP引入本地IP路由表中已經存在的缺省路由
 network 1.1.1.1 mask 32 #配置BGP逐條引入IPv4路由表或IPv6路由表中的路由
 peer 12.1.1.2 password cipher Huawei #配置MD5認證密碼
 peer 12.1.1.2 keychain 1 #配置Keychain認證 Keychain認證推薦使用SHA256和HMAC-SHA256加密算法

 group 1  [ external | internal ] #創建對等體組
 peer 1 as-number 100 #配置EBGP對等體組的AS號
 peer 12.1.1.2 group 1 #向對等體組中加入對等體

 peer 12.1.1.2 valid-ttl-hops 254 #配置BGP GTSM功能。缺省情況下,BGP對等體(組)上未配置GTSM功能
 gtsm default-action { drop | pass}  #設置未匹配GTSM策略的報文的缺省動作。 缺省情況下,未匹配GTSM策略的報文可以通過過濾
 peer { group-name | ipv4-address | ipv6-address } reflect-client #配置路由反射器及其客戶
 refelctor cluster-id 1.1.1.1 #配置路由反射器的集羣ID
 undo reflect between-clients #禁止客戶機之間的路由反射
 routing-table rib-noly [ route-policy route-policy-name ] #禁止BGP將優選的路由下發到IP路由表

 confederation id { as-number-plain | as-number-dot } #配置聯盟ID
 confederation peer-as { as-number-plain | as-number-dot } &<1-32> #指定屬於同一個聯盟的子AS號
 confederation nonstandard #配置聯盟的兼容性

 peer 12.1.1.1 perferred-value value #爲從指定對等體學來的所有路由配置首選值。 缺省情況下,從對等體學來的路由的初始首選值爲0
 defaut local-preference 100 #配置本機的缺省Local_Pref屬性值。 缺省情況下,BGP本地優先級的值爲100

 route-policy AS-path permit node 10 apply as-path 100 { additive | overwrite }  #設置BGP路由的AS_Path屬性
 peer 12.1.1.1 route-policy AS-path export #對向對等體(組)發佈的路由添加AS_Path屬性
 import-route protocol route-policy AS-path #BGP以import方式引入的路由添加AS_Path屬性
 network 12.1.1.1 route-policy AS-path #對BGP以network方式引入的路由添加AS_Path屬性
 bestrouter as-path-ignore #不將AS_Path屬性作爲選路條件
 peer 12.1.1.1 allow-as-loop 100 #允許本地AS編號重複出現 ,缺省情況下,不允許本地AS號重複
 peer 12.1.1.1 public-as-only #配置發送EBGP更新報文時,AS_Path屬性中僅攜帶公有AS編號。 缺省情況下,發送EBGP更新報文時,AS_Path屬性中可以同時攜帶公有AS號和私有AS號
 as-path-limit 255 #配置AS_Path屬性中AS號的最大個數。缺省情況下,AS_Path屬性中AS號的最大個數是255
 peer 12.1.1.1 fake-as 200 #配置EBGP對等體的僞AS號
 default med 0 #配置缺省MED值。配置缺省MED值
 bestroute med-none-as-maximum #設置當路由沒有MED值時將其作爲最大值處理。缺省情況下,當路由屬性中沒有MED值時,BGP在選路時將使用缺省MED值
compare-different-as-med #允許BGP比較屬於任意AS的EBGP對等體的路由的MED值。 缺省情況下,BGP只比較屬於同一AS的EBGP對等體的路由的MED屬性值 deterministic-med #使能Deterministic-MED的功能。在路由選路時優先比較AS_Path最左邊的AS號相同的路由。Deterministic :確定性的
 bestroute med- confederation #比較聯盟內路由的MED值。 缺省情況下,BGP僅比較來自同一AS的路由的MED屬性值


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章