第一步、基础配置
添加端口IP地址和环回地址
[r2]interface g0/0/0
[r2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
[r2-GigabitEthernet0/0/0]q
[r2]interface LoopBack 0
[r2-LoopBack0]ip address 2.2.2.2 24
[r2-LoopBack0]q
[r2]interface g0/0/1
[r2-GigabitEthernet0/0/1]ip address 23.1.1.1 24
[r2-GigabitEthernet0/0/1]q
[r2-GigabitEthernet0/0/2]ip address 2.1.2.1 24
其它路由同理
R2
R3
R4
R5
测试
第二步、在AS2上配置OSPF协议
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
[r2-ospf-1-area-0.0.0.0]network 2.2.2.0 0.0.0.255
[r2-ospf-1-area-0.0.0.0]q
其它路由同理
测试
第三步、其他配置
EBGP
R1与R2建邻
[r1]bgp 1
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.1.1.2 as-number 2
[r2]bgp 2
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 12.1.1.1 as-number 1
IBGP
R2与R3通过环回接口建邻
[r2]bgp 2
[r2-bgp]peer 3.3.3.3 as-number 2
[r2-bgp]peer 3.3.3.3 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与R4、R2与R4建邻同理
EBGP、多条物理链路
添加R4、R5静态路由,使其上的环回可以ping通
[r4]ip route-static 5.5.5.0 24 45.1.1.2
[r4]ip route-static 5.5.5.0 24 54.1.1.2
[r5]ip route-static 4.4.4.0 24 45.1.1.1
[r5]ip route-static 4.4.4.0 24 54.1.1.1
R4与R5通过环回接口建邻
修改路由器上的TTL为2
[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 0
[r5-bgp]peer 4.4.4.4 ebgp-max-hop 2
在R2上修改下一跳为本地地址
[r2-bgp]peer 3.3.3.3 next-hop-local
[r2-bgp]peer 4.4.4.4 next-hop-local
在R4上修改下一跳为本地地址
[r4-bgp]peer 2.2.2.2 next-hop-local
[r4-bgp]peer 3.3.3.3 next-hop-local
R1上查看
R5上查看
测试