BGP源位址問題
------------同一自治系統
引導思路簡圖:
R1:lo0 1.1.1.1
R2:lo1 2.2.2.2
按照上面的配置R2學習不到R1環回口的路由。
我們來看下面的試驗:
試驗環境:
R1:lo0 192.168.10.1 255.255.255.0
lo1 172.16.10.1 255.255.0.0
S1/0 202.110.100.1 255.255.255.0
S1/1 202.110.101.1 255.255.255.0
R2:
lo0 172.16.20.1 255.255.0.0
S1/0 202.110.100.2 255.255.255.0
S1/1 202.110.101.2 255.255.255.0
在R1:
Router(config)#host R1
R1(config)#int lo0
R1(config-if)#ip addr 192.168.10.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#int lo1
R1(config-if)#ip addr 172.16.10.1 255.255.0.0
R1(config-if)#exit
R1(config)#int s1/0
R1(config-if)#ip addr 202.110.100.1 255.255.255.0
R1(config-if)#encap hdlc
R1(config-if)#clock rate 56000
R1(config-if)#int s1/1
R1(config-if)#ip addr 202.110.101.1 255.255.255.0
R1(config-if)#
R1(config)#router bgp 64500
R1(config-router)#neighbor 202.110.100.2 remote-as 64500
R1(config-router)#neighbor 172.16.20.2 remote-as 64500
R1(config-router)#net 192.168.10.0
R1(config-router)#net 172.16.0.0
R1(config-router)#net 202.110.100.0
R1(config-router)#net 202.110.101.0
R1(config)#router rip
R1(config-router)#ver 2
R1(config-router)#net 172.16.10.0
Router(config)#host R2
R2(config)#int lo0
R2(config-if)#ip addr 172.16.20.1 255.255.255.0
R2(config)#int s1/0
R2(config-if)#ip addr 202.110.100.2 255.255.255.0
R2(config-if)#encap hdlc
R2(config-if)#no shut
R2(config)#int s1/1
R2(config-if)#ip addr 202.110.101.2 255.255.255.0
R2(config-if)#exit
R2(config)#router bgp 64500
R2(config-router)#neighbor 202.110.100.1 remote-as 64500
R2(config-router)#neighbor 172.16.10.1 remote-as 64500
R2(config-router)#net 202.110.100.0
R2(config-router)#net 172.16.20.0
R2(config)#router rip
R2(config-router)#ver 2
R2(config-router)#net 202.110.101.0
R2(config-router)#exit
在R2上測試:
R2#show ip ro
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
C 202.110.100.0/24 is directly connected, Serial1/0
R 192.168.10.0/24 [120/1] via 202.110.100.1, 00:00:21, Serial1/0
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.20.0/24 is directly connected, Loopback0
R 172.16.0.0/16 [120/1] via 202.110.100.1, 00:00:21, Serial1/0
由于有備援鍊路,我們可以測試關閉一個端口,看是否還能正常學習到路由。
R1(config-if)#int s1/0
R1(config-if)#shut
在R2上再做測試:
B 192.168.10.0/24 [200/0] via 202.110.100.1, 00:00:10
B 172.16.0.0/16 [200/0] via 202.110.100.1, 00:00:10
R2#
試驗結果正常的,
當兩個端口都關閉後,顯然肯定R2上學不到路由,
R1(config)#int s1/1
再在R2上測試:
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.20.0 is directly connected, Loopback0
這個結果是必然的,我們試驗很順利。
路由器源位址原理:路由器發送bgp包時,預設把“包的流出端口”的ip位址作為包的“源位址”。路由器接受到bgp包後,把包的“源位址”與自己neighbor後的ip位址進行比較:
比對時,正常處理包;不比對時,丢棄該包。
解決的辦法:
通告路由器發送bgp包時,把環回口的ip位址作為源位址,而不使用“包流出端口ip位址”作為包的源位址。
文法:
(config-router)#neighbor 鄰居環回口ip remote-as 自治系統号
(config-router)#neighbor 鄰居環回口ip update-source 環回口
再舉出一例:
相同自治系統bgp通信:
關閉s1/0之前:
關閉s1/0之後:
起到的鍊路備援的作用,試驗結束。
本文轉自shenleigang 51CTO部落格,原文連結:http://blog.51cto.com/shenleigang/152629,如需轉載請自行聯系原作者