僅將本身最優可達的路由發佈給鄰居
什麼纔是最優BGP路由算法
<R2>display bgp routing-table BGP Local router ID is 2.2.2.2 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 6 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 10.10.10.10/32 1.1.1.1 0 100 0 ? *> 22.22.22.22/32 0.0.0.0 0 0 i *> 44.44.44.44/32 24.1.1.4 0 0 200i * i 3.3.3.3 0 100 0 200i *>i 100.100.100.100/32 1.1.1.1 0 100 0 i *>i 101.101.101.101/32 1.1.1.1 0 100 0 ?
注意點:
*號 表示valid(有效)
>號 表示best(最優)
思考一下:爲何RTD到達100網段得下一跳爲10.1.12.1?
BGP在整個AS內 不會改變下一跳 可是BGP在AS和AS之間的時候 下一跳會發生改變
修改方法以下:ide
peer 4.4.4.4 next-hop-local
告訴4.4.4.4你想要到達某一個路由的時候 你把下一跳指向我本身的OK了
BGP路由信息處理
當從BGP鄰居接收到Update報文時,路由器將會執行路徑選擇算法,來爲每一條前綴肯定最佳路徑;
得出的最佳路徑被存儲到本地BGP路由表(Local_RIB)中,而後被提交給本地IP路由表(IP_RIB),以用做安裝考慮;
被選出的有效的最佳路徑路由將會被封裝在Update報文中,發送給對端的BGP鄰居。oop
經過EBGP得到的最優可達路由發佈給全部BGP鄰居(其中包括IBGP和EBGP)學習
經過IBGP得到的最優可達路由不會發布給其餘的IBGP鄰居(IBGP的水平分割
)目的是防止環路3d
BGP與IGP同步(華爲默認關閉,開啓不了)code
undo synchronization
一條從IBGP鄰居學來的路由在發佈給一個BGP鄰居以前,經過IGP必須知道該路由,即BGP與IGP同步
華爲路由器上,默認是將BGP與IGP的同步檢查關閉的,緣由是爲了實現IBGP路由的正常通告。會出現路由黑洞的問題orm
描述以下:
R2 R3 R4屬於AS 200的設備 而且各自的loopback接口都發布到OSPF裏面 R2的2.2.2.2能夠訪問4.4.4.4
R1和R2之間是EBGP關係 用的是物理接口創建
R4和R5之間是EBGP關係 用的是物理接口創建
R2和R4之間是IBGP關係 用的是loopback接口創建
R3設備沒有和任何設備創建BGP關係
基礎配置檢查以下
在R3上面查看OSPF鄰居狀態是否OKrouter
<R3>display ospf peer brief OSPF Process 1 with Router ID 3.3.3.3 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 4.4.4.4 Full 0.0.0.0 GigabitEthernet0/0/1 2.2.2.2 Full ---------------------------------------------------------------------------- <R3>
在R2 R3 R4上查看路由表blog
<R2>display ip routing-table protocol ospf Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : OSPF Destinations : 3 Routes : 3 OSPF routing table status : <Active> Destinations : 3 Routes : 3 Destination/Mask Proto Pre Cost Flags NextHop Interface 3.3.3.3/32 OSPF 10 1 D 192.168.23.3 GigabitEthernet0/0/1 4.4.4.4/32 OSPF 10 2 D 192.168.23.3 GigabitEthernet0/0/1 192.168.34.0/24 OSPF 10 2 D 192.168.23.3 GigabitEthernet0/0/1 OSPF routing table status : <Inactive> Destinations : 0 Routes : 0 <R2>
<R3>display ip routing-table protocol ospf Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : OSPF Destinations : 2 Routes : 2 OSPF routing table status : <Active> Destinations : 2 Routes : 2 Destination/Mask Proto Pre Cost Flags NextHop Interface 2.2.2.2/32 OSPF 10 1 D 192.168.23.2 GigabitEthernet0/0/1 4.4.4.4/32 OSPF 10 1 D 192.168.34.4 GigabitEthernet0/0/0 OSPF routing table status : <Inactive> Destinations : 0 Routes : 0
<R4>display ip routing-table protocol ospf Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : OSPF Destinations : 3 Routes : 3 OSPF routing table status : <Active> Destinations : 3 Routes : 3 Destination/Mask Proto Pre Cost Flags NextHop Interface 2.2.2.2/32 OSPF 10 2 D 192.168.34.3 GigabitEthernet0/0/0 3.3.3.3/32 OSPF 10 1 D 192.168.34.3 GigabitEthernet0/0/0 192.168.23.0/24 OSPF 10 2 D 192.168.34.3 GigabitEthernet0/0/0 OSPF routing table status : <Inactive> Destinations : 0 Routes : 0
檢查BGP的鄰居關係
R1和R2之間的EBGP關係遞歸
<R1>display bgp peer BGP local router ID : 1.1.1.1 Local AS number : 100 Total number of peers : 1 Peers in established state : 1 Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv 192.168.12.2 4 200 17 18 0 00:14:39 Established 1 <R1>
R2的R1的EBGP關係 R2和R4跨鄰居的IBGP關係
<R2>display bgp peer BGP local router ID : 2.2.2.2 Local AS number : 200 Total number of peers : 2 Peers in established state : 2 Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv 4.4.4.4 4 200 17 18 0 00:14:22 Established 1 192.168.12.1 4 100 18 18 0 00:15:02 Established 1
R4和R2的IBGP關係 R4和R5的EBGP關係
<R4>display bgp peer BGP local router ID : 4.4.4.4 Local AS number : 200 Total number of peers : 2 Peers in established state : 2 Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv 2.2.2.2 4 200 17 17 0 00:14:49 Established 1 192.168.45.5 4 300 18 18 0 00:15:21 Established 1
R5和R4的EBGP關係
<R5>display bgp peer BGP local router ID : 5.5.5.5 Local AS number : 300 Total number of peers : 1 Peers in established state : 1 Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv 192.168.45.4 4 200 18 19 0 00:15:34 Established 1 <R5>
路由黑洞實驗現象
在R1的BGP裏面宣告1.1.1.1
在R5的BGP裏面宣告5.5.5.5
# bgp 100 network 1.1.1.1 255.255.255.255 #
# bgp 300 network 5.5.5.5 255.255.255.255 #
在R2上面查看是否學習到關於1.1.1.1和5.5.5.5的BGP路由
<R2>display bgp routing-table BGP Local router ID is 2.2.2.2 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 2 Network NextHop MED LocPrf PrefVal Path/Ogn *> 1.1.1.1/32 192.168.12.1 0 0 100i *>i 5.5.5.5/32 4.4.4.4 0 100 0 300i <R2>
在R4上面查看是否學習到關於1.1.1.1和5.5.5.5的BGP路由
<R4>display bgp routing-table BGP Local router ID is 4.4.4.4 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 2 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 1.1.1.1/32 2.2.2.2 0 100 0 100i *> 5.5.5.5/32 192.168.45.5 0 0 300i <R4>
R4到達1.1.1.1的下一跳是2.2.2.2 由於在R2這邊敲了以下命令
# bgp 200 peer 4.4.4.4 next-hop-local #
在R5上面查看是否學習到關於1.1.1.1的BGP路由
[R5]display bgp routing-table BGP Local router ID is 5.5.5.5 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 2 Network NextHop MED LocPrf PrefVal Path/Ogn *> 1.1.1.1/32 192.168.45.4 0 200 100i *> 5.5.5.5/32 0.0.0.0 0 0 i [R5]
在R5設備上去訪問1.1.1.1
[R5]ping -a 5.5.5.5 1.1.1.1 PING 1.1.1.1: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 1.1.1.1 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss
在R5設備上去訪問tracert 1.1.1.1
<R5>tracert -a 5.5.5.5 1.1.1.1 traceroute to 1.1.1.1(1.1.1.1), max hops: 30 ,packet length: 40,press CTRL_C to break 1 192.168.45.4 50 ms 40 ms 20 ms //發現到R4就中止了 2 * * * 3 * * <R5>
發現數據包交給R4後 R4後面就不通了 咱們看下R4到達1.1.1.1的路由表
<R4>display ip routing-table 1.1.1.1 Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Table : Public Summary Count : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 1.1.1.1/32 IBGP 255 0 RD 2.2.2.2 GigabitEthernet0/0/0 <R4>
發現R4到達1.1.1.1的下一跳是2.2.2.2 R4上面到達2.2.2.2也是非直連網段 R4會遞歸查詢到達2.2.2.2 發現到達2.2.2.2下一跳是R3 由於R4到達1.1.1.1的時候 數據包通過遞歸後 下一跳是R3
<R4>display ip routing-table 2.2.2.2 Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Table : Public Summary Count : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 2.2.2.2/32 OSPF 10 2 D 192.168.34.3 GigabitEthernet0/0/0 <R4>
R4會把數據包交給R3 R3收到後 到達1.1.1.1該如何走呢?
<R3>display ip routing-table 1.1.1.1
發現R3路由表裏面根本就沒有到達1.1.1.1的路由條目 因此R5訪問1.1.1.1就會丟包 R3就像一個吃人的老虎機同樣 只要是R5想要訪問到R1這邊 都會被R3的路由黑洞給吃掉 這個就是路由黑洞分析緣由緣由1:由於R3上沒有運行BGP協議緣由2:BGP能夠跨鄰居創建