一、实验拓扑及要求
要求:
1、AS1存在两个环回,一个地址为192.168.1.0/24该地址不能在任何协议中宣告
AS3中存在两个环回,一个地址为192.168.2.0/24该地址不能在任何协议中宣告,最终要求这两个环回可以互相通讯
2、整个AS2的Ip地址为172.16.0.8/16,请合理划分
3、AS间的骨干链路IP地址随意定制
4、使用BGP协议让整个网络所有设备的环回可以互相访问
5、减少路由条自数量,避免环路出现
二、实验步骤
1.配置ip
r1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R1-GigabitEthernet0/0/0]int l0
[R1-LoopBack0]ip add 1.1.1.1 24
r2
[R2]interface LoopBack 0
[R2-LoopBack0]ip add 172.16.1.2 32
[R2-LoopBack0]int l1
[R2-LoopBack1]ip add 172.16.2.1 24
[R2-LoopBack1]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 172.16.0.1 30
[R2-GigabitEthernet0/0/1]int g0/0/2
[R2-GigabitEthernet0/0/2]ip add 172.16.0.22 30
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
r3
[R3]interface LoopBack 0
[R3-LoopBack0]ip add 172.16.1.3 32
[R3-LoopBack0]int l1
[R3-LoopBack1]ip add 172.16.3.1 24
[R3-LoopBack1]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 172.16.0.2 30
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 172.16.0.5 30
r4
[R4]interface LoopBack 0
[R4-LoopBack0]ip add 172.16.1.4 32
[R4-LoopBack0]int l1
[R4-LoopBack1]ip add 172.16.4.1 24
[R4-LoopBack1]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 172.16.0.6 30
[R4-GigabitEthernet0/0/0]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 172.16.0.9 30
r5
[R5]interface LoopBack 0
[R5-LoopBack0]ip add 172.16.1.5 32
[R5-LoopBack0]int l1
[R5-LoopBack1]ip add 172.16.5.1 24
[R5-LoopBack1]int g0/0/1
[R5-GigabitEthernet0/0/1]ip add 172.16.0.18 30
[R5-GigabitEthernet0/0/1]int g0/0/0
[R5-GigabitEthernet0/0/0]ip add 172.16.0.21 30
r6
[R6]interface LoopBack 0
[R6-LoopBack0]ip add 172.16.1.6 32
[R6-LoopBack0]int l1
[R6-LoopBack1]ip add 172.16.6.1 24
[R6-LoopBack1]int g0/0/1
[R6-GigabitEthernet0/0/1]ip add 172.16.0.14 30
[R6-GigabitEthernet0/0/1]int g0/0/0
[R6-GigabitEthernet0/0/0]ip add 172.16.0.17 30
r7
[R7]interface LoopBack 0
[R7-LoopBack0]ip add 172.16.1.7 32
[R7-LoopBack0]int l1
[R7-LoopBack1]ip add 172.16.7.1 24
[R7-LoopBack1]int g0/0/1
[R7-GigabitEthernet0/0/1]ip add 172.16.0.10 30
[R7-GigabitEthernet0/0/1]int g0/0/0
[R7-GigabitEthernet0/0/0]ip add 172.16.0.13 30
[R7]int g0/0/2
[R7-GigabitEthernet0/0/2]ip add 78.0.0.1 24
r8
[R8]int g0/0/0
[R8-GigabitEthernet0/0/0]ip add 78.0.0.2 24
[R8-GigabitEthernet0/0/0]int l0
[R8-LoopBack0]ip add 8.8.8.8 24
2.为AS2配置OSPF
r2
[AR2]ospf 1
[AR2-ospf-1]area 0
[AR2-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
r3
[AR3]ospf 1
[AR3-ospf-1]area 0
[AR3-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
r4
[AR4]ospf 1
[AR4-ospf-1]area 0
[AR4-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
r5
[AR5]ospf 1
[AR5-ospf-1]area 0
[AR5-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
r6
[AR6]ospf 1
[AR6-ospf-1]area 0
[AR6-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
r7
[AR7]ospf 1
[AR7-ospf-1]area 0
[AR7-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
3.建立BGP对等体
r1
[AR1]bgp 1
[AR1-bgp]router-id 1.1.1.1
[AR1-bgp]peer 12.0.0.2 as-number 2
r2
[AR2]bgp 64512
[AR2-bgp]router-id 2.2.2.2
[AR2-bgp]confederation id 2
[AR2-bgp]confederation peer-as 64513 #声明联邦
[AR2-bgp]peer 12.0.0.1 as-number 1 #与AR1建立BGP对等体
[AR2-bgp]peer 172.16.4.1 as-number 64512
[AR2-bgp]peer 172.16.4.1 connect-interface LoopBack 0
[AR2-bgp]peer 172.16.4.1 next-hop-local #与AR3建立BGP对等体
[AR2-bgp]peer 172.16.132.0 as-number 64513
[AR2-bgp]peer 172.16.132.0 connect-interface LoopBack 0
[AR2-bgp]peer 172.16.132.0 ebgp-max-hop #与AR5建立BGP对等体
[AR2-bgp]peer 172.16.132.0 next-hop-local #修改TTL值
r3
[AR3]bgp 64512
[AR3-bgp]router-id 3.3.3.3
[AR3-bgp]confederation id 2 #声明联邦
[AR3-bgp]peer 172.16.4.0 as-number 64512
[AR3-bgp]peer 172.16.4.0 connect-interface LoopBack 0 #与AR2建立BGP对等体
[AR3-bgp]peer 172.16.4.0 reflect-client
[AR3-bgp]peer 172.16.4.2 as-number 64512
[AR3-bgp]peer 172.16.4.2 connect-interface LoopBack 0 #与AR4建立IBGP对等体
r4
[AR4]bgp 64512
[AR4-bgp]router-id 4.4.4.4
[AR4-bgp]confederation id 2
[AR4-bgp]confederation peer-as 64513 # 声明联邦
[AR4-bgp]peer 172.16.4.1 as-number 64512
[AR4-bgp]peer 172.16.4.1 connect-interface LoopBack 0 #与AR3建立IBGP对等体
[AR4-bgp]peer 172.16.132.2 as-number 64513
[AR4-bgp]peer 172.16.132.2 connect-interface LoopBack 0 #与AR7建立IBGP对等体
[AR4-bgp]peer 172.16.132.2 ebgp-max-hop #修改TTL值
r5
[AR5]bgp 64513
[AR5-bgp]router-id 5.5.5.5
[AR5-bgp]confederation id 2
[AR5-bgp]confederation peer-as 64512 #声明联邦
[AR5-bgp]peer 172.16.132.1 as-number 64513
[AR5-bgp]peer 172.16.132.1 connect-interface LoopBack 0 #与AR6建立BGP对等体
[AR5-bgp]peer 172.16.4.0 as-number 64512
[AR5-bgp]peer 172.16.4.0 connect-interface LoopBack 0 #与AR2建立EBGP对等体
[AR5-bgp]peer 172.16.4.0 ebgp-max-hop 10
[AR5-bgp]peer 172.16.0.1 as-number 64512 # 修改TTL值
r6
[AR6]bgp 64513
[AR6-bgp]router-id 6.6.6.6
[AR6-bgp]confederation id 2 #声明联邦
[AR6-bgp]peer 172.16.132.0 as-number 64513
[AR6-bgp]peer 172.16.132.0 connect-interface LoopBack 0
[AR6-bgp]peer 172.16.132.0 reflect-client #与AR5建立BGP对等体
[AR6-bgp]peer 172.16.132.2 as-number 64513
[AR6-bgp]peer 172.16.132.2 connect-interface LoopBack 0 #与AR7建立BGP对等体
r7
[AR7]bgp 64513
[AR7-bgp]router-id 7.7.7.7
[AR7-bgp]confederation id 2
[AR7-bgp]confederation peer-as 64512 #声明联邦
[AR7-bgp]peer 23.0.0.1 as-number 3 #与AR8建立BGP对等体
[AR7-bgp]peer 172.16.132.1 as-number 64513
[AR7-bgp]peer 172.16.132.1 connect-interface LoopBack 0
[AR7-bgp]peer 172.16.132.1 next-hop-local #与AR6建立BGP对等体
[AR7-bgp]peer 172.16.4.2 as-number 64512
[AR7-bgp]peer 172.16.4.2 connect-interface LoopBack 0 #与AR4建立BGP对等体
[AR7-bgp]peer 172.16.4.2 ebgp-max-hop 10 # 修改TTL值
[AR7-bgp]peer 172.16.4.2 next-hop-local
r8
[AR8]bgp 3
[AR8-bgp]router-id 8.8.8.8
[AR8-bgp]peer 23.0.0.2 as-number 2 # 与AR7建立BGP对等体
3.BGP宣告路由
r1
[AR1-bgp]network 1.1.1.0 24
r8
[AR8-bgp]network 8.8.8.0 24
4.配置GRE
r1
[AR1]interface Tunnel 0/0/0
[AR1-Tunnel0/0/0]ip address 100.0.0.1 24
[AR1-Tunnel0/0/0]tunnel-protocol gre
[AR1-Tunnel0/0/0]source 1.1.1.1
[AR1-Tunnel0/0/0]description 8.8.8.8
[AR1]ip route-static 192.168.2.0 24 100.0.0.2
r8
[AR8]interface Tunnel 0/0/0
[AR8-Tunnel0/0/0]ip address 100.0.0.2 24
[AR8-Tunnel0/0/0]tunnel-protocol gre
[AR8-Tunnel0/0/0]source 8.8.8.8
[AR8-Tunnel0/0/0]description 1.1.1.1
[AR8]ip route-static 192.168.1.0 24 100.0.0.1
三、全网可通检验
r1 ping r8
<AR1>ping -a 1.1.1.18.8.8.8
PING 8.8.8.8:56data bytes, press CTRL_C to break
Reply from 8.8.8.8: bytes=56 Sequence=l ttl=251 time=40 ms
Reply from 8.8.8.8: bytes=56 Sequence=2 tt1=251 time=40 ms
Reply from 8.8.8.8: bytes=56 Sequence=3 ttl=251 time=40 ms
Reply from 8.8.8.8: bytes=56 Sequence=4 tt1=251 time=30 ms
Reply from 8.8.8.8: bytes=56 Sequence=5 ttl=251 time=40 ms
--- 8.8.8.8 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max=30/40/50 ms
GRE测试
[AR1]ping-a 1.1.1.18.8.8.8
PING 8.8.8.8: 56 data bytes, press CTRL C to break
Reply from 8.8.8.8: bytes=56 Sequence=l ttl=251 time=60 ms
Reply from 8.8.8.8: bytes=56 Sequence=2 tt1=251 time=40 ms
Reply from 8.8.8.8: bytes=56 Sequence=3 ttl=251 time=40 ms
Reply from 8.8.8.8: bytes=56 Sequence=4 ttl=251 time=40 ms
Reply from 8.8.8.8: bytes=56 Sequence=5 ttl=251 time=40 ms
---8.8.8.8 ping statistics---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max= 40/48/80 ms