根据拓扑图配置IP
建立EBGP关系
R1和R2
[r1-bgp]bgp 1
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.1.1.2 as-number 2
[r2-bgp]bgp 2
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 12.1.1.1 as-number 1
R4和R5
[r4]ip route-static 5.5.5.5 32 54.1.1.2 //因为静态IP与BGP中所宣告的IP掩码不同,建邻使用的 [r4]ip route-static 5.5.5.5 32 45.1.1.2 IP与所宣告的IP不同,所以可以传递出去
[r4]ip route-static 99.1.1.0 24 45.1.1.2
[r4]ip route-static 99.1.1.0 24 54.1.1.2
[r4-bgp]bgp 2
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 5.5.5.5 as-number 3
[r4-bgp]peer 5.5.5.5 ebgp-max-hop 2
[r4-bgp]peer 5.5.5.5 connect-interface LoopBack0
[r5]ip route-static 4.4.4.4 32 45.1.1.1
[r5]ip route-static 4.4.4.4 32 54.1.1.1
[r5-bgp]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 ebgp-max-hop 2
[r5-bgp]peer 4.4.4.4 connect-interface LoopBack0
建立IBGP关系
R2和R3
[r2-bgp]peer 3.3.3.3 as-number 2
[r2-bgp]peer 3.3.3.3 connect-interface LoopBack0
[r3-bgp]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 LoopBack0
R2和R4
[r2-bgp]peer 4.4.4.4 as-number 2
[r2-bgp]peer 4.4.4.4 connect-interface LoopBack0
[r4-bgp]peer 2.2.2.2 as-number 2
[r4-bgp]peer 2.2.2.2 connect-interface LoopBack0
R3和R4
[r4-bgp]peer 3.3.3.3 as-number 2
[r4-bgp]peer 3.3.3.3 connect-interface LoopBack0
[r3-bgp]peer 4.4.4.4 as-number 2
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack0
BGP宣告
R1
[r1-bgp]network 1.1.1.0 24
R2
[r2-bgp]network 2.2.2.0 24
R3
[r3-bgp]network 3.3.3.0 24
R4
[r4-bgp]network 4.4.4.0 24
R5
[r5-bgp]network 5.5.5.0 24
测试
R1
R3
R5
R5环回PingR1环回