一、实验需求
除R5的5.5.5.0环回外,其他所有的环回均可互相一访问。
二、实验步骤
1.配置ip
2.建立邻居关系
2.1 R1和R2建立直连的EBGP邻居关系
[r1]bgp 1
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.1.1.2 as-number 2
要建的话双方都要建下面配置R2
[r2]bgp 2
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 12.1.1.1 as-number 1
2.2 R2和R3建立IGBP
[r2]bgp 2
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 3.3.3.3 as-number 2
[r2-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r2-bgp]peer 4.4.4.4 as-number 2
[r2-bgp]peer 4.4.4.4 connect-interface LoopBack 0[r3]bgp 2
[r3-bgp]router-id 3.3.3.3
[r3-bgp]peer 2.2.2.2 as-number 2
[r3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r3-bgp]peer 4.4.4.4 as-number 2
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack 0[r4]bgp 2
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 3.3.3.3 as-number 2
[r4-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r4-bgp]peer 2.2.2.2 as-number 2
[r4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
2.3 R4和R5之间配置EBGP
1.配置静态路由
[r4]undo ip route-static 5.5.5.0 24 45.1.1.2
[r4]ip route-static 5.5.5.5 32 45.1.1.2[r5]undo ip route-static 4.4.4.0 24 45.1.1.1
[r5]ip route-static 4.4.4.4 32 45.1.1.12.建立EBGP邻居关系
[r4]bgp 2
[r4-bgp]peer 5.5.5.5 as-number 3
[r4-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r5]bgp 3
[r5-bgp]router-id 5.5.5.5
[r5-bgp]peer 4.4.4.4 as-number 2
[r5-bgp]peer 4.4.4.4 connect-interface LoopBack 03.更改TTL值
[r4-bgp]peer 4.4.4.4 ebgp-max-hop 2
[r5-bgp]peer 5.5.5.5 ebgp-max-hop 2
3.BGP宣告
AS1:
R1
[r1]bgp 1
[r1-bgp]network 1.1.1.0 24[r1-bgp]network 12.1.1.0 24
AS2:
R2
[r2]bgp 2
[r2-bgp]network 2.2.2.0 24[r2-bgp]network 12.1.1.0 24
[r2-bgp]network 23.1.1.0 24R3
[r3]bgp 2
[r3-bgp]network 3.3.3.0 24[r3-bgp]network 23.1.1.0 24
[r3-bgp]network 34.1.1.0 24R4
[r4]bgp 2
[r4-bgp]network 4.4.4.0 24[r4-bgp]network 34.1.1.0 24
[r4-bgp]network 45.1.1.0 24
[r4-bgp]network 54.1.1.0 24AS3:
R5
[r5]bgp 3
[r5-bgp]network 5.5.5.0 24[r5-bgp]network 45.1.1.0 24
[r5-bgp]network 54.1.1.0 24
4.选路问题
4.1 R3学习到R1/R5路由不优
需要将R2与R4将路由条目传递给下一个邻居时,修改下一跳为本地地址
R2
[r2]bgp 2
[r2-bgp]peer 3.3.3.3 next-hop-local
[r2-bgp]peer 4.4.4.4 next-hop-localR4
[r4]bgp 2
[r4-bgp]peer 2.2.2.2 next-hop-local
[r4-bgp]peer 3.3.3.3 next-hop-local
4.2 悖论
查看R4的BGP表会发现到5环回5.5.5.0不优
此时应该把之前在R4为了和R5建邻的静态修改一下,将原来的24位改为32位即可
[r4]undo ip route-static 5.5.5.0 24
[r4]ip route-static 5.5.5.5 32 45.1.1.2
[r4]ip route-static 5.5.5.5 32 54.1.1.2
R1也会学习到R5路由
5.测试