一.实验拓扑图
![](https://i-blog.csdnimg.cn/blog_migrate/5f999b8bb7156d8e01575431bb3d3161.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a1823807848b3807bf1548677ebce0e7.png)
二.详细配置
R1
interface GigabitEthernet0/0/0
ip address 12.1.1.1 255.255.255.0
interface LoopBack0
ip address 1.1.1.1 255.255.255.0
interface LoopBack1
ip address 10.1.1.1 255.255.255.0
bgp 1
router-id 1.1.1.1
peer 12.1.1.2 as-number 2
ipv4-family unicast
undo synchronization
network 10.1.1.0 255.255.255.0
peer 12.1.1.2 enable
R2
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
interface GigabitEthernet0/0/1
ip address 172.16.0.1 255.255.255.252
interface GigabitEthernet0/0/2
ip address 172.16.0.9 255.255.255.252
interface LoopBack0
ip address 172.16.1.2 255.255.255.255
interface LoopBack1
ip address 172.16.2.1 255.255.255.0
bgp 64512
router-id 172.16.1.2
confederation id 2
confederation peer-as 64513
peer 12.1.1.1 as-number 1
peer 172.16.1.3 as-number 64512
peer 172.16.1.3 connect-interface LoopBack0
peer 172.16.1.5 as-number 64513
peer 172.16.1.5 ebgp-max-hop 2
peer 172.16.1.5 connect-interface LoopBack0
ipv4-family unicast
undo synchronization
network 172.16.0.0 255.255.248.0
peer 12.1.1.1 enable
peer 172.16.1.3 enable
peer 172.16.1.3 next-hop-local
peer 172.16.1.5 enable
peer 172.16.1.5 next-hop-local
ospf 1
area 0.0.0.0
network 172.16.0.0 0.0.255.255
ip route-static 172.16.0.0 255.255.248.0 NULL0
R3
interface GigabitEthernet0/0/0
ip address 172.16.0.2 255.255.255.252
interface GigabitEthernet0/0/1
ip address 172.16.0.5 255.255.255.252
interface LoopBack0
ip address 172.16.1.3 255.255.255.255
interface LoopBack1
ip address 172.16.3.1 255.255.255.0
bgp 64512
router-id 172.16.1.3
confederation id 2
peer 172.16.1.2 as-number 64512
peer 172.16.1.2 connect-interface LoopBack0
peer 172.16.1.4 as-number 64512
peer 172.16.1.4 connect-interface LoopBack0
ipv4-family unicast
undo synchronization
peer 172.16.1.2 enable
peer 172.16.1.4 enable
peer 172.16.1.4 reflect-client
ospf 1
area 0.0.0.0
network 172.16.0.0 0.0.255.255
R4
interface GigabitEthernet0/0/0
ip address 172.16.0.6 255.255.255.252
interface GigabitEthernet0/0/1
ip address 172.16.0.21 255.255.255.252
interface LoopBack0
ip address 172.16.1.4 255.255.255.255
interface LoopBack1
ip address 172.16.4.1 255.255.255.0
bgp 64512
router-id 172.16.1.4
confederation id 2
confederation peer-as 64513
peer 172.16.1.3 as-number 64512
peer 172.16.1.3 connect-interface LoopBack0
peer 172.16.1.7 as-number 64513
peer 172.16.1.7 ebgp-max-hop 2
peer 172.16.1.7 connect-interface LoopBack0
ipv4-family unicast
undo synchronization
peer 172.16.1.3 enable
peer 172.16.1.7 enable
ospf 1
area 0.0.0.0
network 172.16.0.0 0.0.255.255
R5
interface GigabitEthernet0/0/0
ip address 172.16.0.10 255.255.255.252
interface GigabitEthernet0/0/1
ip address 172.16.0.13 255.255.255.252
interface LoopBack0
ip address 172.16.1.5 255.255.255.255
interface LoopBack1
ip address 172.16.5.1 255.255.255.0
bgp 64513
router-id 172.16.1.5
confederation id 2
confederation peer-as 64512
peer 172.16.1.2 as-number 64512
peer 172.16.1.2 ebgp-max-hop 2
peer 172.16.1.2 connect-interface LoopBack0
peer 172.16.1.6 as-number 64513
peer 172.16.1.6 connect-interface LoopBack0
ipv4-family unicast
undo synchronization
peer 172.16.1.2 enable
peer 172.16.1.6 enable
ospf 1
area 0.0.0.0
network 172.16.0.0 0.0.255.255
R6
interface GigabitEthernet0/0/0
ip address 172.16.0.14 255.255.255.252
interface GigabitEthernet0/0/1
ip address 172.16.0.17 255.255.255.252
interface LoopBack0
ip address 172.16.1.6 255.255.255.255
interface LoopBack1
ip address 172.16.6.1 255.255.255.0
bgp 64513
router-id 172.16.1.6
confederation id 2
peer 172.16.1.5 as-number 64513
peer 172.16.1.5 connect-interface LoopBack0
peer 172.16.1.7 as-number 64513
peer 172.16.1.7 connect-interface LoopBack0
ipv4-family unicast
undo synchronization
peer 172.16.1.5 enable
peer 172.16.1.7 enable
peer 172.16.1.7 reflect-client
ospf 1
area 0.0.0.0
network 172.16.0.0 0.0.255.255
R7
interface GigabitEthernet0/0/0
ip address 172.16.0.18 255.255.255.252
interface GigabitEthernet0/0/1
ip address 172.16.0.22 255.255.255.252
interface GigabitEthernet0/0/2
ip address 78.1.1.7 255.255.255.0
interface LoopBack0
ip address 172.16.1.7 255.255.255.255
interface LoopBack1
ip address 172.16.7.1 255.255.255.0
bgp 64513
router-id 172.16.1.7
confederation id 2
confederation peer-as 64512
peer 78.1.1.8 as-number 3
peer 172.16.1.4 as-number 64512
peer 172.16.1.4 ebgp-max-hop 2
peer 172.16.1.4 connect-interface LoopBack0
peer 172.16.1.6 as-number 64513
peer 172.16.1.6 connect-interface LoopBack0
ipv4-family unicast
undo synchronization
network 172.16.0.0 255.255.248.0
peer 78.1.1.8 enable
peer 172.16.1.4 enable
peer 172.16.1.4 next-hop-local
peer 172.16.1.6 enable
peer 172.16.1.6 next-hop-local
ospf 1
area 0.0.0.0
network 172.16.0.0 0.0.255.255
ip route-static 172.16.0.0 255.255.248.0 NULL0
R8
interface GigabitEthernet0/0/0
ip address 78.1.1.8 255.255.255.0
interface GigabitEthernet0/0/1
interface GigabitEthernet0/0/2
interface LoopBack0
ip address 8.8.8.8 255.255.255.255
interface LoopBack1
ip address 10.1.8.1 255.255.255.0
bgp 3
router-id 8.8.8.8
peer 78.1.1.7 as-number 2
ipv4-family unicast
undo synchronization
network 10.1.8.0 255.255.255.0
peer 78.1.1.7 enable