1、首先对于各个路由器进行地址配置
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]a 0
[r2-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
------------------------------------------------------------------
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]a 0
[r3-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
------------------------------------------------------------------
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]a 0
[r4-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
------------------------------------------------------------------
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]a 0
[r5-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
------------------------------------------------------------------
[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]a 0
[r6-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
------------------------------------------------------------------
[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]a 0
[r7-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
汇总后的ospf
[r2]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 9 Routes : 10
OSPF routing table status : <Active>
Destinations : 9 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
172.16.0.8/29 OSPF 10 2 D 172.16.0.2 GigabitEthernet
0/0/1
172.16.0.24/29 OSPF 10 2 D 172.16.0.18 GigabitEthernet
0/0/2
172.16.0.32/29 OSPF 10 3 D 172.16.0.18 GigabitEthernet
0/0/2
172.16.0.40/29 OSPF 10 3 D 172.16.0.2 GigabitEthernet
0/0/1
172.16.1.1/32 OSPF 10 1 D 172.16.0.2 GigabitEthernet
0/0/1
172.16.2.1/32 OSPF 10 2 D 172.16.0.2 GigabitEthernet
0/0/1
172.16.3.1/32 OSPF 10 1 D 172.16.0.18 GigabitEthernet
0/0/2
172.16.4.1/32 OSPF 10 2 D 172.16.0.18 GigabitEthernet
0/0/2
172.16.5.1/32 OSPF 10 3 D 172.16.0.2 GigabitEthernet
0/0/1
OSPF 10 3 D 172.16.0.18 GigabitEthernet
0/0/2
OSPF routing table status : <Inactive>
Destinations : 0 Routes : 0
2、其次在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 172.16.0.0 0.0.255.255
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
[R6]ospf 1 router-id 6.6.6.6
[R6-ospf-1]area 0
[R6-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
[R7]ospf 1 router-id 7.7.7.7
[R7-ospf-1]area 0
[R7-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
3、配置bgp
[R1]bgp 1
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 12.1.1.2 as-number 2
[R2]bgp 64512
[R2-bgp]router-id 2.2.2.2
[R2-bgp]confederation id 2
[R2-bgp]confederation peer-as 64513
[R2-bgp]peer 12.1.1.1 as-number 1
[R2-bgp]peer 172.16.0.5 as-number 64513
[R2-bgp]peer 172.16.0.5 connect-interface LoopBack0
[R2-bgp]peer 172.16.0.5 ebgp-max-hop 2
[R2-bgp]peer 172.16.0.3 as-number 64512
[R2-bgp]peer 172.16.0.3 connect-interface LoopBack0
[R3]bgp 64512
[R3-bgp]router-id 3.3.3.3
[R3-bgp]confederation id 2
[R3-bgp]peer 172.16.0.2 as-number 64512
[R3-bgp]peer 172.16.0.2 connect-interface LoopBack0
[R3-bgp]peer 172.16.0.4 as-number 64512
[R3-bgp]peer 172.16.0.4 connect-interface LoopBack0
[R4]bgp 64512
[R4-bgp]router-id 4.4.4.4
[R4-bgp]confederation id 2
[R4-bgp]confederation peer-as 64513
[R4-bgp]peer 172.16.0.7 as-number 64513
[R4-bgp]peer 172.16.0.7 connect-interface LoopBack0
[R4-bgp]peer 172.16.0.7 ebgp-max-hop 2
[R4-bgp]peer 172.16.0.3 as-number 64512
[R4-bgp]peer 172.16.0.3 connect-interface LoopBack0
[R5]bgp 64513
[R5-bgp]router-id 5.5.5.5
[R5-bgp]confederation id 2
[R5-bgp]confederation peer-as 64512
[R5-bgp]peer 172.16.0.2 as-number 64512
[R5-bgp]peer 172.16.0.2 connect-interface LoopBack0
[R5-bgp]peer 172.16.0.2 ebgp-max-hop 2
[R5-bgp]peer 172.16.0.6 as-number 64513
[R5-bgp]peer 172.16.0.6 connect-interface LoopBack0
[R6]bgp 64513
[R6-bgp]router-id 6.6.6.6
[R6-bgp]confederation id 2
[R6-bgp]peer 172.16.0.5 as-number 64513
[R6-bgp]peer 172.16.0.5 connect-interface LoopBack0
[R6-bgp]peer 172.16.0.7 as-number 64513
[R6-bgp]peer 172.16.0.7 connect-interface LoopBack0
[R7]bgp 64513
[R7-bgp]router-id 7.7.7.7
[R7-bgp]confederation id 2
[R7-bgp]confederation peer-as 64512
[R7-bgp]peer 172.16.0.4 as-number 64512
[R7-bgp]peer 172.16.0.4 connect-interface LoopBack0
[R7-bgp]peer 172.16.0.4 ebgp-max-hop 2
[R7-bgp]peer 172.16.0.6 as-number 64513
[R7-bgp]peer 172.16.0.6 connect-interface LoopBack0
[R7-bgp]peer 78.1.1.2 as-number 3
[R8]bgp 3
[R8-bgp]router-id 8.8.8.8
[R8-bgp]peer 78.1.1.1 as-number 2
修改R2和R7路由传递给邻居的下一跳为本地
[R2-bgp]peer 172.16.0.3 next-hop-local
[R7-bgp]peer 172.16.0.6 next-hop-local
创建路由反射器
[R3-bgp]peer 172.16.0.2 reflect-client
[R6-bgp]peer 172.16.0.7 reflect-client
4、BGP的宣告配置
R1:[R1-bgp]network 1.1.1.0 255.255.255.0
R2 利用空接口进行汇总宣告
[R2]ip route-static 172.16.0.0 255.255.0.0 NULL0
[R1-bgp]network 172.16.0.0 0.0.255.255
R7 利用空接口进行汇总宣告
[R2]ip route-static 172.16.0.0 255.255.0.0 NULL0
[R1-bgp]network 172.16.0.0 0.0.255.255
R8:[R1-bgp]network 8.8.8.0 255.255.255.0
联邦
[r2]bgp 642512
[r2-bgp]router-id 2.2.2.2
[r2-bgp]confederation id 2
[r2-bgp]peer 172.16.0.3 as-number 64512
[r2-bgp]peer 172.16.0.3 connect-interface LoopBack 0
[r3]bgp 642512
[r3-bgp]router-id 3.3.3.3
[r3-bgp]confederation id 2
[r3-bgp]peer 172.16.0.2 as-number 64512
[r3-bgp]peer 172.16.0.2 connect-interface LoopBack 0