二.需求
1. 完成所有 IGP 配置
2. 使用直连接口建立 EBGP
3. 使用环回接口建立 IBGP
4. 使用 connect-interface 命令修改 IBGP 建邻的源接口
5. 使用 next-hop-local 命令修改路由传递的下一跳属性
R1
r1]interface g0/0/0
[r1-GigabitEthernet0/0/0]ip address 12.0.0.1 24
[r1]interface LoopBack 0
[r1-LoopBack0]ip address 1.1.1.1 32
配置BGP(建立EBGP对等体)
[r1]bgp 100
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.0.0.2 as-number 200
[r1-bgp]network 1.1.1.1 32
R2
[r2]interface g 0/0/0
[r2-GigabitEthernet0/0/0]ip address 12.0.0.2 24
[r2]interface g0/0/1
[r2-GigabitEthernet0/0/1]ip address 23.0.0.2 24
[r2]interface LoopBack 0
[r2-LoopBack0]ip address 2.2.2.2 32
OSPF配置
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 23.0.0.0 0.0.0.255
[r2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
BGP配置(建立EBGP和IBGP 对等体)
[r2]bgp 200
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 12.0.0.1 as-number 100
[r2-bgp]peer 3.3.3.3 as-number 200
[r2-bgp]import-route ospf 1
[r2-bgp]peer 3.3.3.3 connect-interface LoopBack0
[r2-bgp]peer 4.4.4.4 as-number 200
[r2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r2-bgp]peer 3.3.3.3 next-hop-local
[r2-bgp]peer 4.4.4.4 next-hop-local
[r2-bgp]import-route ospf 1
R3
[r3]interface g0/0/0
[r3-GigabitEthernet0/0/0]ip address 23.0.0.3 24
[r3]interface g0/0/1
[r3-GigabitEthernet0/0/1]ip address 34.0.0.3 24
[r3]interface LoopBack 0
[r3-LoopBack0]ip address 3.3.3.3 32
OSPF配置
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 23.0.0.0 0.0.0.255
[r3-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
BGP配置
[r3]bgp 200
[r3-bgp]router-id 3.3.3.3
[r3-bgp]peer 2.2.2.2 as-number 200
[r3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r3-bgp]peer 4.4.4.4 as-number 200
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
R4
[r3]interface g0/0/0
[r3-GigabitEthernet0/0/0]ip address 23.0.0.3 24
[r3]interface g0/0/1
[r3-GigabitEthernet0/0/1]ip address 34.0.0.3 24
[r3]interface LoopBack 0
[r3-LoopBack0]ip address 3.3.3.3 32
OSPF配置
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 23.0.0.0 0.0.0.255
[r3-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
BGP配置
[r3]bgp 200
[r3-bgp]router-id 3.3.3.3
[r3-bgp]peer 2.2.2.2 as-number 200
[r3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r3-bgp]peer 4.4.4.4 as-number 200
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
R5
[r5]interface g0/0/0
[r5-GigabitEthernet0/0/0]ip address 45.0.0.5 24
[r5]interface LoopBack 0
[r5-LoopBack0]ip address 5.5.5.5 32
BGP配置
[r5]bgp 300
[r5-bgp]router-id 5.5.5.5
[r5-bgp]ip route-static 4.4.4.4 32 45.0.0.4
[r5-bgp]peer 4.4.4.4 as-number 200
[r5-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r5-bgp]peer 4.4.4.4 ebgp-max-hop 2
[r5-bgp]network 5.5.5.5 32