天天看點

使用回環位址建立bgp鄰居

一、拓撲圖:

二、詳細說明與配置:

1、配置各接口IP位址,以及R1和R2運作RIP V2,并關閉自動彙總,保證鍊路的互通性:

2、我們先在R1上配置BGP,這次我們不用對端接口位址來建立bgp的鄰居,而是用loopback位址來建立,因為大家知道loopback位址是不會down 的,對于bgp而言這種方式是最好的了。這樣有利于bgp鄰居關系的穩健性。下面看一下R1的配置:

R1(config)#router bgp 64512

R1(config-router)#net 172.16.0.0 mask 255.255.255.0

R1(config-router)#net 172.16.1.0 mask 255.255.255.0

R1(config-router)#net 172.16.255.0 mask 255.255.255.252

R1(config-router)#nei 172.16.16.1 remote 64512(指定對端鄰居的loopback0接口)

3、我們先不管能不能建立起鄰居,先在R2上配置,看一下隻指定鄰居回環位址之後,能不能建立起bgp鄰居:

R2(config)#router bgp 64512

R2(config-router)#net 172.16.255.0 mask 255.255.255.252

R2(config-router)#net 172.16.16.0 mask 255.255.255.0

R2(config-router)#net 10.1.255.0 mask 255.255.255.252

R2(config-router)#nei 172.16.0.1 remote 64512 (指定對端鄰居的loopback0接口)

4、檢視一下有沒有建立起鄰居:

R1#show ip bgp sum

BGP router identifier 172.16.1.1, local AS number 64512

BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

172.16.16.1     4 64512       0       0        0    0    0 never    Active (還在嘗試連接配接,發現并沒有建立起來)

5、我們在R1上debug ip bgp all看一下:

R1#debug ip bgp all

BGP debugging is on for all address families

R1#

*Mar  1 02:49:46.535: BGP: 172.16.16.1 open active, local address 172.16.255.1

*Mar  1 02:49:46.627: BGP: 172.16.16.1 open failed: Connection refused by remote host, open active delayed 29991ms (35000ms max, 28% jitter) (發現被遠端的主機拒絕了)

6、看來隻單指定回環口的鄰居并不行,我們還需要在兩邊指定用loopback接口做更新源:

R1(config-router)#nei 172.16.16.1 update-source loopback 0

R2(config-router)#nei 172.16.0.1 update-source lo0(分别在R1,R2指定用自己的lo0接口和對端建鄰居)

7、再來看一下鄰居關系:

R1#show ip bgp summary

BGP table version is 7, main routing table version 7

5 network entries using 585 bytes of memory

6 path entries using 312 bytes of memory

3/2 BGP path/bestpath attribute entries using 372 bytes of memory

0 BGP route-map cache entries using 0 bytes of memory

0 BGP filter-list cache entries using 0 bytes of memory

BGP using 1269 total bytes of memory

BGP activity 8/3 prefixes, 9/3 paths, scan interval 60 secs

172.16.16.1     4 64512      12      12        7    0    0 00:07:26        3 (鄰居起來了)

二、R1和R2建立起來了鄰居關系,拓撲中R2和R3并不在同一個AS當中。那麼R2和R3該怎樣去做呢?

1、R2和R3在不同的AS當中,我們需要指定ebgp多跳,并且由于R3沒有運作RIP V2協定,為了保證它們之間有TCP連接配接關系,我們到時候用靜态路由去指定好了。看一下R1的配置:

R2(config)#ip route 192.168.0.0 255.255.255.0 10.1.255.2

R2(config-router)#nei 192.168.0.1 remote 64513

R2(config-router)#nei 192.168.0.1 update-source lo0

R2(config-router)#nei 192.168.0.1 ebgp-multihop 2

2、在R3上的配置:

R3(config)#ip route 172.16.16.0 255.255.255.0 10.1.255.1(建靜态由路保證指定位址TCP可達)

R3(config-router)#net 192.168.0.0

R3(config-router)#net 192.168.1.0 (注入直連網絡到BGP程序當中,有類位址沒帶子網釋出)

R3(config-router)#net 10.1.255.0 mask 255.255.255.252(無類位址帶子網釋出)

R3(config-router)#nei 172.16.16.1 remote 64512

R3(config-router)#nei 172.16.16.1 update-source lo0 (用本地的lo0和對端指定鄰居)

R3(config-router)#nei 172.16.16.1 ebgp-multihop 2 (指出ebgp的鄰居位址存在多跳特性)

3、再到R2上看一下bgp的鄰居彙總:

R2#show ip bgp summary

BGP router identifier 172.16.16.1, local AS number 64512

BGP table version is 24, main routing table version 24

7 network entries using 819 bytes of memory

8 path entries using 416 bytes of memory

4/3 BGP path/bestpath attribute entries using 496 bytes of memory

1 BGP AS-PATH entries using 24 bytes of memory

BGP using 1755 total bytes of memory

BGP activity 9/2 prefixes, 13/5 paths, scan interval 60 secs

172.16.0.1      4 64512      41      47       24    0    0 00:36:55        3

192.168.0.1     4 64513      14      20       24    0    0 00:03:32        3  (至此兩條鄰居都能看到了)

三、設定鄰居的下一跳:

1、現在我們再來看一下R1、R2、R3的bgp路由表:

R1#sh ip route bgp

     10.0.0.0/30 is subnetted, 1 subnets

B       10.1.255.0 [200/0] via 172.16.16.1, 01:16:50 (發現隻有一條bgp路由)

R2#show ip route

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks

C       172.16.255.0/30 is directly connected, FastEthernet0/0

C       172.16.16.0/24 is directly connected, Loopback0

R       172.16.0.0/24 [120/1] via 172.16.255.1, 00:00:16, FastEthernet0/0

R       172.16.1.0/24 [120/1] via 172.16.255.1, 00:00:16, FastEthernet0/0 (ibgp内以RIP來走)

C       10.1.255.0 is directly connected, Serial1/1

S    192.168.0.0/24 [1/0] via 10.1.255.2

B    192.168.1.0/24 [20/0] via 192.168.0.1, 02:20:11 (學到了域外的ebgp)

R3#sh ip route bgp

B       172.16.255.0/30 [20/0] via 172.16.16.1, 01:16:15

B       172.16.0.0/24 [20/0] via 172.16.16.1, 01:16:15

B       172.16.1.0/24 [20/0] via 172.16.16.1, 01:16:15  (能夠全部學到,并以BGP呈現)

2、因為R1和R2運作了RIP 協定,R3運作的是靜态路由。而且BGP運作的是兩個AS,從上面的各路由器學到的bgp鄰居的情況,我們看到了R3能學到所有的bgp路由,但R1隻學到了一條路由,原因是BGP speaker從IBGP獲得的路由不向它的IBGP相鄰體通告,是以R2并沒有把學到的ebgp的路由通告給R1,那麼我們隻需要在R2上指定從R3那邊來的路由指定下一跳為自己,把它通告給R1:

R2(config-router)#nei 172.16.0.1 next-hop-self

3、現在再來看一下R1的bgp路由表:

B       10.1.255.0 [200/0] via 172.16.16.1, 02:43:56

B    192.168.0.0/24 [200/0] via 172.16.16.1, 00:00:02

B    192.168.1.0/24 [200/0] via 172.16.16.1, 00:00:02  (現在學到了三條了。)

四、總結:因為隻要路由器開啟,回環口一直都會是up狀态。用回環位址去建立bgp連接配接能夠提高bgp鄰居關系的穩健性,但需要注意的是配置時需保證到loopback位址的TCP可達性,而且還要指出用本地回環位址和對端建立鄰居,當和ebgp端跨子網建立鄰居時,則需要使用ebgp多跳功能來指定ebgp鄰居,最大支援255跳。BGP speaker從IBGP獲得的路由不向它的IBGP相鄰體通告,是以我們要在邊緣的路由器上指定下一跳為自己進行路由的轉發通告。在BGP中所說的下一跳,是指下一跳AS,而并非是下一跳路由器。由EBGP學來的路由資訊,在傳遞給IBGP鄰居時,不改變其下一跳屬性值。

本文轉自wxs-163 51CTO部落格,原文連結:http://blog.51cto.com/supercisco/264891

繼續閱讀