- 实验拓扑
- 实验要求
- 按照如图所示配置IP地址,R2,R3,R4,R5,R6,R7分别配置Loopback0口地址作为 OSPF的Router_id和IBGP邻居地址,地址格式为 X.X.X.X/32,X为设备编号。R1上配置Loopback 1口模拟业务网段。
- AS 2内部配置OSPF,用于实现BGP的TCP可达。
- AS 2内部建立BGP联盟,联盟AS为AS 2,包含两个子AS为AS 64512和AS 64513,R1和R2建立EBGP邻居,R7和R8建立EBGP邻居,R2和R5建立EBGP邻居,子AS内部建立IBGP全连接。
- AS1中存在两个环回,一个地址为192.168.1.0/24,该地址不能在任何协议中宣告
AS3中存在两个环回,一个地址为192.168.2.8/24,该地址不能在任何协议中宣告,最终要求这两个环回可以ping通。
5、使用BGp协议让整个网络所有设备的环回可以互相访问。
6、减少路由条目数量,避免环路出现。
三.实验配置
1.配置IP地址部分
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
[R1-GigabitEthernet0/0/0]int LoopBack 0
[R1-LoopBack0]ip add 1.1.1.1 32
[R1-LoopBack0]int LoopBack 1
[R1-LoopBack1]ip add 192.168.1.1 24
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[R2-GigabitEthernet0/0/0]int g0/0/2
[R2-GigabitEthernet0/0/2]ip add 172.16.1.21 30
[R2-GigabitEthernet0/0/2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 172.16.1.1 30
[R2-GigabitEthernet0/0/1]int LoopBack 0
[R2-LoopBack0]ip add 2.2.2.2 32
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 172.16.1.2 30
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 172.16.1.5 30
[R3-GigabitEthernet0/0/1]int LoopBack 0
[R3-LoopBack0]ip add 3.3.3.3 32
[R3-LoopBack0]int LoopBack 1
[R3-LoopBack1]ip add 172.16.3.1 24
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 172.16.1.5 30
[R4-GigabitEthernet0/0/0]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 172.16.1.9 30
[R4-GigabitEthernet0/0/1]int LoopBack 0
[R4-LoopBack0]ip add 4.4.4.4 32
[R4-LoopBack0]int LoopBack 1
[R4-LoopBack1]ip add 172.16.4.1 24
[R5]int g0/0/0
[R5-GigabitEthernet0/0/0]ip add 172.16.1.22 30
[R5-GigabitEthernet0/0/0]int g0/0/1
[R5-GigabitEthernet0/0/1]ip add 172.16.1.17 30
[R5-GigabitEthernet0/0/1]int LoopBack 0
[R5-LoopBack0]ip add 5.5.5.5 32
[R5-LoopBack0]int LoopBack 1
[R5-LoopBack1]ip add 172.16.5.1 24
[R6]int g0/0/0
[R6-GigabitEthernet0/0/0]ip add 172.16.1.18 30
[R6-GigabitEthernet0/0/0]int g0/0/1
[R6-GigabitEthernet0/0/1]ip add 172.16.1.13 30
[R6-GigabitEthernet0/0/1]int LoopBack 0
[R6-LoopBack0]ip add 6.6.6.6 32
[R6-LoopBack0]int LoopBack 1
[R6-LoopBack1]ip add 172.16.6.1 24
[R7]int g0/0/0
[R7-GigabitEthernet0/0/0]ip add 172.16.1.14 30
[R7-GigabitEthernet0/0/0]int g0/0/1
[R7-GigabitEthernet0/0/1]ip add 172.16.1.10 30
[R7-GigabitEthernet0/0/1]int g0/0/2
[R7-GigabitEthernet0/0/2]ip add 34.1.1.7 24
[R7-GigabitEthernet0/0/2]int LoopBack 0
[R7-LoopBack0]ip add 7.7.7.7 32
[R7-LoopBack0]int LoopBack 1
[R7-LoopBack1]ip add 172.16.7.1 24
[R8]int g0/0/0
[R8-GigabitEthernet0/0/0]ip add 34.1.1.8 24
[R8-GigabitEthernet0/0/0]int LoopBack 0
[R8-LoopBack0]ip add 8.8.8.8 32
[R8-LoopBack0]int LoopBack 1
[R8-LoopBack1]ip add 192.168.2.1 24
- AS 200内部配置OSPF部分
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.3
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.3
[R3-ospf-1-area-0.0.0.0]network 172.16.1.4 0.0.0.3
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 172.16.1.4 0.0.0.3
[R4-ospf-1-area-0.0.0.0]network 172.16.1.8 0.0.0.3
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]network 5.5.5.5 0.0.0.0
[R5-ospf-1-area-0.0.0.0]network 172.16.1.22 0.0.0.3
[R5-ospf-1-area-0.0.0.0]network 172.16.1.17 0.0.0.3
[R6]ospf 1 router-id 6.6.6.6
[R6-ospf-1]area 0
[R6-ospf-1-area-0.0.0.0]network 6.6.6.6 0.0.0.0
[R6-ospf-1-area-0.0.0.0]network 172.16.1.22 0.0.0.3
[R6-ospf-1-area-0.0.0.0]network 172.16.1.17 0.0.0.3
[R7]ospf 1 router-id 7.7.7.7
[R7-ospf-1]area 0
[R7-ospf-1-area-0.0.0.0]network 7.7.。77 0.0.0.0
[R7-ospf-1-area-0.0.0.0]network 172.16.1.22 0.0.0.3
[R7-ospf-1-area-0.0.0.0]network 172.16.1.17 0.0.0.3
测试:R2/R3/R4/R5/R6/R7的OSPF路由表,以R2为例
- AS 2内部建立BGP联盟,联盟AS为 AS 2,包含两个子AS 6512和AS 64513。
[R1]bgp 1
[R1-bgp]peer 12.1.1.2 as-number 2
[R2]bgp 65412
[R2-bgp]confederation id 2
[R2-bgp]confederation peer-as 64513
[R2-bgp]peer 12.1.1.1 as-number 1
[R2-bgp]peer 3.3.3.3 as-number 64512
[R2-bgp]peer 3.3.3.3 connect-interface l0
[R2-bgp]peer 3.3.3.3 next-hop-local
[R2-bgp]peer 5.5.5.5 as-number 64513
[R2-bgp]peer 5.5.5.5 next-hop-local
[R2-bgp]peer 5.5.5.5 ebgp-max-hop
[R3]bgp 64512
[R3-bgp]confederation id 2
[R3-bgp]peer 2.2.2.2 as-number 64512
[R3-bgp]peer 2.2.2.2 connect-interface l0
[R3-bgp]peer 4.4.4.4 as-number 64512
[R3-bgp]peer 4.4.4.4 connect-interface l0
[R4]bgp 64512
[R4-bgp]confederation id 2
[R4-bgp]peer 3.3.3.3 as-number 64512
[R4-bgp]peer 3.3.3.3 connect-interface l0
[R5]bgp 64513
[R5-bgp]confederation id 2
[R5-bgp]confederation peer-as 64512
[R5-bgp]peer 2.2.2.2 as-number 64512
[R5-bgp]peer 2.2.2.2 connect-interface l0
[R5-bgp]peer 2.2.2.2 next-hop-local
[R5-bgp]peer 2.2.2.2 ebgp-max-hop
[R5-bgp]peer 4.4.4.4 as-number 64513
[R5-bgp]peer 4.4.4.4 connect-interface l0
[R6]bgp 64513
[R6-bgp]confederation id 2
[R6-bgp]peer 5.5.5.5 as-number 64513
[R6-bgp]peer 5.5.5.5 connect-interface l0
[R6-bgp]peer 7.7.7.7 as-number 64513
[R6-bgp]peer 7.7.7.7 connect-interface l0
[R7]bgp 65413
[R7-bgp]confederation id 2
[R7-bgp]peer 34.1.1.8 as-number 3
[R7-bgp]peer 6.6.6.6 as-number 64513
[R7-bgp]peer 6.6.6.6 connect-interface l0
[R7-bgp]peer 6.6.6.6 next-hop-local
[R8]bgp 1
[R8-bgp]peer 34.1.1.7 as-number 2
测试:查看各路由器BGP邻居是否建立,以R2和R7为例
- R1、R8把环回宣告进BGP,要求AS 2内部所有路由器都能够学习到该业务网段路由
[R1]bgp 1
[R1-bgp]network 1.1.1.1 32
[R8]bgp 3
[R8-bgp]network 8.8.8.8 32
测试:用R1环回pingR8环回
- 因为BGP的水平分割的缘故,我们会发现R4、R6、R7学不到R1、R8环回的路由。
解决方法:将R3、R6配置为路由反射器
[r3]bgp 64512
[r3-bgp]peer 2.2.2.2 reflect-client
[r3-bgp]peer 7.7.7.7 reflect-client
[r6]bgp 64513
[r6-bgp]peer 5.5.5.5 reflect-client
[r6-bgp]peer 7.7.7.7 reflect-client
发现其他路由器学到路由,以R4、R7为例
6、减少路由条目数量,避免环路出现
[r3-bgp]aggregate 172.16.0.0 16 detail-suppressed
[r3]ip route-static 172.16.0.0 16 NULL 0
[r4-bgp]aggregate 172.16.0.0 16 detail-suppressed
[r4]ip route-static 172.16.0.0 16 NULL 0
[r5-bgp]aggregate 172.16.0.0 16 detail-suppressed
[r5]ip route-static 172.16.0.0 16 NULL 0
[r6-bgp]aggregate 172.16.0.0 16 detail-suppressed
[r6]ip route-static 172.16.0.0 16 NULL 0
[r7-bgp]aggregate 172.16.0.0 16 detail-suppressed
[r7]ip route-static 172.16.0.0 16 NULL 0
- 使用VPN技术创建隧道,使R1业务网段和R8业务网段进行通信
[r1]int t0/0/0
[r1-Tunnel0/0/0]ip address 100.1.1.1 24
[r1-Tunnel0/0/0]tunnel-protocol gre
[r1-Tunnel0/0/0]source 1.1.1.1
[r1-Tunnel0/0/0]destination 8.8.8.8
[r1]ip route-static 192.168.2.0 24 100.1.1.2
[r8]int t0/0/0
[r8-Tunnel0/0/0]ip address 100.1.1.2 24
[r8-Tunnel0/0/0]tunnel-protocol gre
[r8-Tunnel0/0/0]source 8.8.8.8
[r8-Tunnel0/0/0]destination 1.1.1.1
[r8]ip route-static 192.168.1.0 24 100.1.1.1
测试:R1业务网段pingR8业务网段