1. 程式人生 > 實用技巧 >BGP

BGP


一、背景

1、介紹

邊界閘道器協議---網際網路霸主

IGP--內部閘道器協議:RGP、eigrp、ospf、isis

EGP--外部閘道器協議:EGP、BGP

small:rip

big:eigrp

large:ospf/isis

huge:egp/bgp

2、術語

2.1、AS

自治系統:一組被統一管理的路由器(可以說一個運營商是一個自治系統,或有多個自治系統)

一個AS相當於一個ZSP

範圍:1-65535

  • 共有:1-64511

  • 私有:64512-65535

2.2、對等體(鄰居)

ebgp pear:外部鄰居(兩個AS之間)

ibgp bear:內部鄰居

二、基本特性

1、osi層次

  • RGP、BGP是在應用層,BGP基於TCP179埠、rip基於udp520
  • ospf、eigrp是在傳輸層
  • isis是在網路層

2、分類

有類:ripv1、igrp

無類:ripv2、eigrp、isis、ospf、bgp

---無類:VLSM、CIDR

3、執行特徵

高階距離向量或者又叫高階路徑向量

4、選路原則

BGP按照如下項序選擇一條沒有環路並且可用的路由:

  • 權重:Prefer highest weight (local to router).
  • 優先順序:Prefer highest local preference (global within AS).
  • 起源於本地:Prefer route originated by the local router (nexthop = 0.0.0.0).
  • 最短AS路徑:Prefer shortest AS path.
  • 最低的起源屬性:Prefer lowest origin code (GP <EGP < incomplete).
  • 最低的MED : Prefer lowest MED.
  • EBGP優於IBGP :Prefer EBGP path over IBGP path.
  • 最近的IGP鄰居:Prefer the path through the closestIGP neighbor.
  • 生存最長的路由:Prefer oldest route for EBGP paths.
  • 最低的router-id : Prefer the path with the lowestneighbor BGP routerID.
  • 最低的IP地址:Prefer the path with the lowest neighbor IP address.

5、最佳路徑

三、基本部署

 1 [r1]=>
 2 router bgp 100
 3 no synchronization     //關閉同步
 4 bgp router-id 1.1.1.1
 5 bgp log-neighbor-changes
 6 network 1.1.1.1 mask 255.255.255.255
 7 neighbor 12.1.1.2 remote-as 2345
 8 no auto-summary
 9 
10 [r2]= >
11 router bgp 2345
12 no synchronization
13 bgp router-id 2.2.2.2
14 bgp log-neighbor-changes
15 network 2.2.2.2 mask 255.255.255.255
16 neighbor 12.1.1.1 remote-as 100
17 no auto-summary
18 
19 router bgp 2345
20 neighbor 3.3.3.3 remqte-as 2345
21 neighbor 3.3.3.3 update-source Loopback1 
22 
23 [r3]= >
24 router bgp 2345
25 no synchronization
26 bgp router-id 3.3.3.3
27 bgp log-neighbor-changes
28 neighbor 2.2.2.2 remote as 2345
29 neighbor 2.2.2.2 update-source Loopback1
30 no auto-summary
31 
32 //檢視bgp鄰居表
33 show ip bgp summary
34 show ip bgp neighbor
35 
36 //檢視bgp資料庫/拓撲表
37 show ip bgp
38 
39 //檢視bgp路由
40 show ip route bgp
41 
42 //檢視bgp配置
43 show run | s r b

四、路由分組

四個資料包:

  • open message

  • keepalive message

    每60秒騷擾一下對方,告訴對方,我還活著

  • update message //更新包

   網路可達資訊裡面就是儲存的路由條目

  • notification message

    用於對BGP的錯誤程序進行批錯

五、鄰居建立

ebgp基於loopback建立鄰居

1、通過靜態路由指向對方環回介面

2、基於靜態路由的連通性,建立bgp鄰居

3、開啟[ebgp 多跳 multi-hop]

程式碼:

 1 [r1]
 2 ip route 2.2.2.2 255.255.255.255 Serial3/0
 3 
 4 router bgp 100
 5 bgp router-id 1.1.1.1 !
 6 network 1.1.1.1 mask 255.255.255.255
 7 neighbor 2.2.2.2 remote-as 2345
 8 neighbor 2.2.2.2 ebgp-multihop 2
 9 neighbor 2.2.2.2 update-source Loopback1
10 //r2與r1同,就只是network和neighbor不同

BGP鄰居建立條件: 本地neighbor的地址,必須跟對方bgp源ip地址是一致的

ebpg傳送的包的ttl=1

狀態資訊

更新源檢測

六、網路設計

1、BGP網路拓撲發展演變

會出現路由黑洞

解決路由黑洞:---重分發:

很麻煩、解決:---bgp同步:老闆本的bgp預設開啟同步:

路由要根據BGP學到,也要根據內部協議學的才可以