实验拓扑:
实验步骤:
①配置接口ip地址
[R1]
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 10.0.12.1/24 up up
LoopBack0 1.1.1.1/24 up up(s)
LoopBack1 11.11.11.11/24 up up(s)
[R2]
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 10.0.12.2/24 up up
GigabitEthernet0/0/1 10.0.23.2/24 up up
LoopBack0 2.2.2.2/24 up up(s)
[R3]
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/1 10.0.23.3/24 up up
GigabitEthernet0/0/2 10.0.34.3/24 up up
LoopBack0 3.3.3.3/24 up up(s)
[R4]
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 10.0.45.4/24 up up
GigabitEthernet0/0/1 10.0.54.4/24 up up
GigabitEthernet0/0/2 10.0.34.4/24 up up
LoopBack0 4.4.4.4/24 up up(s)
[R5]
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 10.0.45.5/24 up up
GigabitEthernet0/0/1 10.0.54.5/24 up up
LoopBack0 5.5.5.5/24 up up(s)
LoopBack1 55.55.55.55/24 up up(s)
②给运行ebgp的路由器写静态
[R1]
ip route-static 2.2.2.0 255.255.255.0 10.0.12.2
[R2]
ip route-static 1.1.1.0 255.255.255.0 10.0.12.1
[R4]
ip route-static 5.5.5.0 255.255.255.0 10.0.45.5
ip route-static 5.5.5.0 255.255.255.0 10.0.54.5
[R5]
ip route-static 4.4.4.0 255.255.255.0 10.0.45.4
ip route-static 4.4.4.0 255.255.255.0 10.0.54.4
③给运行ibgp的路由器启动态路由协议
[R2]
rip 1
version 2
network 2.0.0.0
network 10.0.0.0
[R3]
rip 1
version 2
network 3.0.0.0
network 10.0.0.0
[R4]
rip 1
version 2
network 4.0.0.0
network 10.0.0.0
④启动bgp并宣告
[R1]
bgp 1
router-id 1.1.1.1
peer 2.2.2.2 as-number 2
peer 2.2.2.2 ebgp-max-hop 2
peer 2.2.2.2 connect-interface LoopBack0
network 11.11.11.0 24
[R2]
bgp 2
router-id 2.2.2.2
peer 1.1.1.1 as-number 1
peer 1.1.1.1 ebgp-max-hop 2
peer 1.1.1.1 connect-interface LoopBack0
peer 3.3.3.3 as-number 2
peer 3.3.3.3 connect-interface LoopBack0
peer 4.4.4.4 as-number 2
peer 4.4.4.4 connect-interface LoopBack0
peer 3.3.3.3 next-hop-local
peer 4.4.4.4 next-hop-local
[R3]
bgp 2
router-id 3.3.3.3
peer 2.2.2.2 as-number 2
peer 2.2.2.2 connect-interface LoopBack0
peer 4.4.4.4 as-number 2
peer 4.4.4.4 connect-interface LoopBack0
peer 2.2.2.2 next-hop-local
peer 4.4.4.4 next-hop-local
[R4]
bgp 2
router-id 4.4.4.4
peer 2.2.2.2 as-number 2
peer 2.2.2.2 connect-interface LoopBack0
peer 3.3.3.3 as-number 2
peer 3.3.3.3 connect-interface LoopBack0
peer 5.5.5.5 as-number 3
peer 5.5.5.5 ebgp-max-hop 2
peer 5.5.5.5 connect-interface LoopBack0
peer 2.2.2.2 next-hop-local
peer 3.3.3.3 next-hop-local
[R5]
bgp 3
router-id 5.5.5.5
peer 4.4.4.4 as-number 2
peer 4.4.4.4 ebgp-max-hop 2
peer 4.4.4.4 connect-interface LoopBack0
nework 55.55.55.0 24
⑤测试