吳剛
摘 要: 邊界網(wǎng)關(guān)協(xié)議BGP適合在多個(gè)AS自治系統(tǒng)間交換路由信息,對(duì)運(yùn)營(yíng)管理系統(tǒng)的集成和協(xié)調(diào)起著重要作用,通常對(duì)配置多個(gè)AS之間的路由轉(zhuǎn)發(fā)及IBGP的路由同步存在諸多問(wèn)題。通過(guò)搭建多自治系統(tǒng)的實(shí)驗(yàn)環(huán)境,在BGP網(wǎng)絡(luò)中采用路由重發(fā)布、內(nèi)部鄰居設(shè)定、指定IBGP的next-hop、啟用路由同步、路由匯總等方法,給出了針對(duì)所存在問(wèn)題的解決方案并給予了論證。
關(guān)鍵詞: BGP; IBGP; 自治系統(tǒng); 路由重發(fā)布; 路由同步
中圖分類(lèi)號(hào):TP393.2 文獻(xiàn)標(biāo)志碼:A 文章編號(hào):1006-8228(2014)03-14-03
0 引言
BGP協(xié)議適合在大的自治系統(tǒng)間交換路由信息,應(yīng)用在這樣幾種環(huán)境:AS允許數(shù)據(jù)包穿過(guò)它到達(dá)其他AS;有到其他AS的多條連接;必須對(duì)進(jìn)入和離開(kāi)AS的數(shù)據(jù)流進(jìn)行控制;典型的環(huán)境是ISP[1]。
BGP路由選擇的前提條件是:路由同步、無(wú)環(huán)路、下一跳可達(dá)(優(yōu)化)。
BGP路由選擇判斷條件比較多,判斷優(yōu)先順序依如下步驟:
⑴ 選擇最高的本地優(yōu)先級(jí);
⑵ 選擇本路由器始發(fā)的路由(next hop=0.0.0.0);
⑶ 選擇最短的AS路徑;
⑷ 選擇最小的起源code (IGP ⑸ 選擇最小的MED; ⑹ 選擇從EBGP鄰居學(xué)到的路由; ⑺ 選擇到達(dá)BGP下一跳最短的路由(根據(jù)IGP路由選擇); ⑻ 選擇從EBGP鄰居學(xué)到最老的路由(oldest route:意為鄰居計(jì)時(shí)器的值更大); ⑼ 選擇最小的鄰居路由器Router ID; ⑽ 選擇最小的鄰居路由器IP地址(BGP neighbor配置那個(gè)地址)[1]。 1 實(shí)驗(yàn)環(huán)境 用一個(gè)實(shí)驗(yàn)環(huán)境來(lái)驗(yàn)證BGP的配置、IBGP和IGP的同步、AS系統(tǒng)間的轉(zhuǎn)發(fā)及穿透,如圖1所示。 圖1 BGP系統(tǒng)拓?fù)?/p> 在圖1所示的實(shí)驗(yàn)環(huán)境中,包含三個(gè)自治系統(tǒng),其中AS65100含有R2、R3、R4三臺(tái)路由器,R2和R4創(chuàng)建IBGP鄰居關(guān)系,同時(shí),這三臺(tái)路由器運(yùn)行OSPF的IGP內(nèi)部路由協(xié)議;為了便于路由匯總,減少AS之間的路由信息條目,AS65100內(nèi)部規(guī)劃的網(wǎng)絡(luò)地址范圍可以匯總為60.100.0.0/16地址段。 R1和R2是兩個(gè)不同自治系統(tǒng)的邊界網(wǎng)關(guān),建立EBGP鄰居關(guān)系; R4和R5是兩個(gè)不同自治系統(tǒng)的邊界網(wǎng)關(guān),建立EBGP鄰居關(guān)系。 2 設(shè)備配置命令序列及功能 2.1 R1配置 interface Loopback0 ip address 60.202.11.1 255.255.255.0 interface FastEthernet0/0 ip address 60.200.12.1 255.255.255.0 router bgp 65202 synchronization network 60.202.11.0 mask 255.255.255.0 ??!通告本系統(tǒng)中的網(wǎng)絡(luò)段,不通告AS外部連接網(wǎng)絡(luò)段 neighbor 60.200.12.2 remote-as 65100 no auto-summary[3] 2.2 R2配置 interface FastEthernet0/0 ip address 60.100.23.2 255.255.255.0 interface FastEthernet0/1 ip address 60.200.12.2 255.255.255.0 router ospf 1 ??!AS65100系統(tǒng)內(nèi)部使用OSPF路由協(xié)議 redistribute bgp 65100 metric 1000 subnets ??!為了使EBGP傳播的路由信息和IBGP保持同步,需要把EBGP路由再發(fā)布到OSPF路由信息中。 network 60.100.23.0 0.0.0.255 area 0 ! router bgp 65100 bgp log-neighbor-changes neighbor 60.100.34.4 remote-as 65100 neighbor 60.200.12.1 remote-as 65202 neighbor 60.100.34.4 next-hop-self ??!IBGP保持路由條目的下一跳信息,IBGP鄰居收到的路由下一跳是不可達(dá)的外部AS網(wǎng)關(guān),所以通告IBGP鄰居,EBGP的下一跳路由指向自己,這是可達(dá)的路由條目。 no auto-summary synchronization ??!啟用同步功能,防止路由黑洞 network 60.100.0.0 mask 255.255.0.0 ?。∠蛲獠緼S系統(tǒng)通告一條匯總的網(wǎng)段 ip route 60.100.0.0 255.255.0.0 Null0 ??!需要在IGP表中構(gòu)造一條對(duì)應(yīng)的匯總網(wǎng)段路由,不然就不能用network通告匯總路由[2]。
2.3 R3配置
interface FastEthernet0/0
ip address 60.100.34.3 255.255.255.0
interface FastEthernet0/1
ip address 60.100.23.3 255.255.255.0
router ospf 1
network 60.100.23.0 0.0.0.255 area 0
network 60.100.34.0 0.0.0.255 area 0
R3中不需要運(yùn)行BGP協(xié)議建立網(wǎng)狀的IBGP鄰居關(guān)系,BGP協(xié)議運(yùn)行在TCP協(xié)議中,可以通過(guò)IGP路由傳遞,只要本AS中的邊界網(wǎng)關(guān)互相建立IBGP鄰居關(guān)系就可。
2.4 R4配置
interface FastEthernet0/0
ip address 60.100.34.4 255.255.255.0
interface FastEthernet0/1
ip address 60.201.45.4 255.255.255.0
router ospf 1
log-adjacency-changes
redistribute bgp 65100 metric 1000 subnets
network 60.100.34.0 0.0.0.255 area 0
router bgp 65100
bgp log-neighbor-changes
neighbor 60.100.23.2 remote-as 65100
neighbor 60.201.45.5 remote-as 65203
neighbor 60.100.23.2 next-hop-self
no auto-summary
synchronization
network 60.100.0.0 mask 255.255.0.0
ip route 60.100.0.0 255.255.0.0 Null0
2.5 R5配置
interface Loopback0
ip address 60.203.55.5 255.255.255.0
interface FastEthernet0/0
ip address 60.201.45.5 255.255.255.0
router bgp 65203
synchronization
network 60.203.55.0 mask 255.255.255.0
neighbor 60.201.45.4 remote-as 65100
no auto-summary
3 實(shí)驗(yàn)結(jié)果輸出信息
3.1 R4輸出信息
R4上顯示TCP連接:
R4#show tcp brief
TCB Local Address Foreign Address (state)
66702968 60.100.34.4.179 60.100.23.2.45640 ESTAB
675625E0 60.201.45.4.46746 60.201.45.5.179 ESTAB
標(biāo)明BGP通過(guò)TCP的179端口建立了連接。
R4上顯示BGP鄰居信息:
R4#show ip bgp neighbor
BGP neighbor is 60.100.23.2, remote AS 65100, internal link
BGP version 4, remote router ID 60.200.12.2
BGP state=Established, up for 00:41:03
BGP neighbor is 60.201.45.5, remote AS 65203, external link
BGP version 4, remote router ID 60.203.55.5
BGP state=Established, up for 00:41:06
IBGP鄰居和EBGP鄰居都已經(jīng)建立起來(lái)了。
顯示鄰居摘要信息:
R4#show ip bgp summary
BGP router identifier 60.201.45.4, local AS number 65100
BGP table version is 5, main routing table version 5
3 network entries using 360 bytes of memory
4 path entries using 208 bytes of memory
5/3 BGP path/bestpath attribute entries using 620 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
60.100.23.2 4 65100 51 51 5 0 0 00:45:05 2
60.201.45.5 4 65203 49 49 5 0 0 00:44:56 1
查看BGP表信息:
R4#show ip bgp
BGP table version is 5, local router ID is 60.201.45.4
Status codes: s suppressed, d damped, h history,
* valid, > best, i - internal, r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i60.100.0.0/16 60.100.23.2 0 100 0 i
*> 0.0.0.0 0 32768 i
r>i60.202.11.0/24 60.100.23.2 0 100 0 65202 i
*> 60.203.55.0/24 60.201.45.5 0 0 65203 i
r>i60.202.11.0/24這一項(xiàng)中,“r”表明選用了IGP的路由,BGP路由加入路由表失效,但是“>”表示是最優(yōu)路由,仍然可以傳遞給外部EBGP。緊接著的“i”表示是IBGP傳遞過(guò)來(lái)的路由[4]。
R4#show ip route
60.0.0.0/8 is variably subnetted, 6 subnets, 2 masks
O 60.100.23.0/24 [110/20] via 60.100.34.3, 00:49:10,
FastEthernet0/0
S 60.100.0.0/16 is directly connected, Null0
C 60.100.34.0/24 is directly connected, FastEthernet0/0
B 60.203.55.0/24 [20/0] via 60.201.45.5, 00:48:29
C 60.201.45.0/24 is directly connected, FastEthernet0/1
O E2 60.202.11.0/24 [110/1000] via 60.100.34.3, 00:49:10,
FastEthernet0/0
R4#
3.2 R1輸出信息
R1#show ip bgp
Network Next Hop Metric LocPrf Weight Path
*>60.100.0.0/16 60.200.12.2 0 0 65100 i
*>60.202.11.0/24 0.0.0.0 0 32768 i
*>60.203.55.0/24 60.200.12.2 0 65100 65203 i
R1#show ip route
60.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
B 60.100.0.0/16 [20/0] via 60.200.12.2, 01:01:53
B 60.203.55.0/24 [20/0] via 60.200.12.2, 01:00:25
C 60.200.12.0/24 is directly connected, FastEthernet0/0
C 60.202.11.0/24 is directly connected, Loopback0
R1#ping 60.203.55.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 60.203.55.5,
timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
缺省情況下,R1去ping AS65203的網(wǎng)段,是用物理接口地址60.200.12.1,而這個(gè)網(wǎng)段在另外兩個(gè)AS系統(tǒng)中是沒(méi)有路由條目的,也不必要去通告這條AS系統(tǒng)間的網(wǎng)段,所以是ping 不通的。
R1#ping 60.203.55.5 source 60.202.11.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 60.203.55.5,
timeout is 2 seconds:
Packet sent with a source address of 60.202.11.1
?。。。?!
Success rate is 100 percent (5/5), round-trip min/avg/max
=172/258/332 ms
根據(jù)source來(lái)指定的源地址是AS65202內(nèi)部的網(wǎng)段,這是BGP對(duì)外通告的網(wǎng)段,在另外兩個(gè)AS是有BGP路由,可以順利ping通。
3.3 R2輸出信息
R2#show ip bgp
Network Next Hop Metric LocPrf Weight Path
* i60.100.0.0/16 60.100.34.4 0 100 0 i
*> 0.0.0.0 0 32768 i
*> 60.202.11.0/24 60.200.12.1 0 0 65202 i
r>i60.203.55.0/24 60.100.34.4 0 100 0 65203 i
可以獲取兩個(gè)EBGP的路由。
R2#show ip route
60.0.0.0/8 is variably subnetted, 6 subnets, 2 masks
C 60.100.23.0/24 is directly connected, FastEthernet0/0
S 60.100.0.0/16 is directly connected, Null0
O 60.100.34.0/24 [110/20] via 60.100.23.3, 01:02:29,
FastEthernet0/0
O E2 60.203.55.0/24 [110/1000] via 60.100.23.3,
01:01:36, FastEthernet0/0
C 60.200.12.0/24 is directly connected, FastEthernet0/1
B 60.202.11.0/24 [20/0] via 60.200.12.1, 01:03:04
R2#
3.4 R3輸出信息
R3#show ip route
60.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
C 60.100.23.0/24 is directly connected, FastEthernet0/1
O E2 60.100.0.0/16 [110/1000] via 60.100.34.4, 01:04:22,
FastEthernet0/0
[110/1000] via 60.100.23.2, 01:04:22, FastEthernet0/1
C 60.100.34.0/24 is directly connected, FastEthernet0/0
O E2 60.203.55.0/24 [110/1000] via 60.100.34.4,
01:03:30, FastEthernet0/0
O E2 60.202.11.0/24 [110/1000] via 60.100.23.2,
01:04:22, FastEthernet0/1
R3#
3.5 R5輸出信息
R5#show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 60.100.0.0/16 60.201.45.4 0 0 65100 i
*> 60.202.11.0/24 60.201.45.4 0 65100 65202 i
*> 60.203.55.0/24 0.0.0.0 0 32768 i
可以正常獲得AS65202的路由信息,并加入到路由表中。
R5#show ip route
B 60.100.0.0/16 [20/0] via 60.201.45.4, 01:04:56
C 60.203.55.0/24 is directly connected, Loopback0
C 60.201.45.0/24 is directly connected, FastEthernet0/0
B 60.202.11.0/24 [20/0] via 60.201.45.4, 01:04:56
4 結(jié)束語(yǔ)
本文對(duì)BGP的多AS系統(tǒng)路由配置方案解決了如下問(wèn)題:AS系統(tǒng)內(nèi)的IGP和IBGP的同步;AS系統(tǒng)間的路由轉(zhuǎn)發(fā);ping 通各AS內(nèi)部網(wǎng)絡(luò)。因?yàn)锽GP不同的自治系統(tǒng)可能分屬于不同的運(yùn)營(yíng)商,所以路由轉(zhuǎn)發(fā)需要控制過(guò)濾,不同的自治系統(tǒng)還需要認(rèn)證。對(duì)于多種屬性靈活控制選路,以及BGP的路由黑洞解決辦法等技術(shù)還有待進(jìn)一步研究論證。
參考文獻(xiàn):
[1] 程慶梅.創(chuàng)建高級(jí)路由型互聯(lián)網(wǎng)[M].機(jī)械工業(yè)出版社,2012.
[2] 程慶梅.創(chuàng)建高級(jí)路由型互聯(lián)網(wǎng)實(shí)訓(xùn)手冊(cè)[M].機(jī)械工業(yè)出版社,2012.
[3] 斯桃枝.路由協(xié)議與交換技術(shù)[M].清華大學(xué)出版社,2012.
[4] 龐玲.邊界路由器BGP協(xié)議的脆弱性[J].計(jì)算機(jī)系統(tǒng)應(yīng)用,2013.22
(1):157-161