实验要求:
- R6为ISP只能配置IP地址,R1-R5的环回为私有网段
- R1/4/5为全连的MGRE结构
- R1/2/3为星型的拓扑结构,R1为中心站点
- 所有私有网段可以互相通讯,私有网段使用OSPF协议完成
搭建实验拓扑及IP规划
实验步骤:
一、配置IP与环回
给除了R6(ISP)外的其他路由写缺省路由,指向R6,实现公网互通
注:
- R1 上有两条缺省路由,其余均一条缺省路由
- 全连接:10.1.1.1 /24
- 中心站点:10.1.2.1 /24
测试:
二、R1/4/5为全连的MGRE结构
R1 配置
#
interface Tunnel0/0/0
shutdown
注:在向R5、R4注册时需要先关闭接口,若不关闭则会导致后面nhrp无法注册
ip address 10.1.1.1 255.255.255.0
tunnel-protocol gre p2mp
source GigabitEthernet0/0/1
nhrp entry 10.1.1.4 46.1.1.4 register
nhrp entry 10.1.1.5 56.1.1.5 register
undo shoudown
ospf network-type broadcast 若修改为P2MP,则还要修改Hello时间
#
R4 配置
#
interface Tunnel0/0/0
shutdown
ip address 10.1.1.4 255.255.255.0
tunnel-protocol gre p2mp
source GigabitEthernet0/0/0
ospf network-type broadcast
nhrp entry 10.1.1.1 16.1.1.1 register
nhrp entry 10.1.1.5 56.1.1.5 register
undo shoudown
ospf network-type broadcast
#
R5 配置
#
interface Tunnel0/0/0
shutdown
注:在向R1、R4注册时需要先关闭接口
ip address 10.1.1.5 255.255.255.0
tunnel-protocol gre p2mp
source GigabitEthernet0/0/0
ospf network-type broadcast
nhrp entry 10.1.1.1 16.1.1.1 register
nhrp entry 10.1.1.4 46.1.1.4 register
undo shoudown
ospf network-type broadcast
#
三、R1/2/3为星型的拓扑结构,R1为中心站点
- R1为中心站点,把R2/R3中的tunnel接口优先级改为0
- 接口工作方式为broadcast
R1 配置(中心站点)
#
interface Tunnel0/0/1
ip address 10.1.2.1 255.255.255.0
tunnel-protocol gre p2mp
source 16.2.2.1
nhrp entry multicast dynamic 开启伪广播域
ospf network-type broadcast 修改接口网络类型
#
R2 配置
#
interface Tunnel0/0/1
ip address 10.1.2.2 255.255.255.0
tunnel-protocol gre p2mp
source GigabitEthernet0/0/0
nhrp entry 10.1.2.1 16.2.2.1 register
ospf dr-priority 0 放弃选举
ospf network-type broadcast
#
R3 配置
#
interface Tunnel0/0/1
ip address 10.1.2.3 255.255.255.0
tunnel-protocol gre p2mp
source GigabitEthernet0/0/0
nhrp entry 10.1.2.1 16.2.2.1 register
ospf dr-priority 0
ospf network-type broadcast
#
四、开启OSPF
R1 配置
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 192.168.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]network 16.2.2.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]network 16.1.1.1 0.0.0.0
R2 配置
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 192.168.2.1 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 26.2.2.2 0.0.0.0
R3、R4、R5步骤相同
六、测试
[R1]ping 192.168.2.1
PING 192.168.2.1: 56 data bytes, press CTRL_C to break
Reply from 192.168.2.1: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 192.168.2.1: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 192.168.2.1: bytes=56 Sequence=3 ttl=255 time=30 ms
Reply from 192.168.2.1: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 192.168.2.1: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 192.168.2.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/24/30 ms
[R1]ping 192.168.3.1
PING 192.168.3.1: 56 data bytes, press CTRL_C to break
Reply from 192.168.3.1: bytes=56 Sequence=1 ttl=254 time=30 ms
Reply from 192.168.3.1: bytes=56 Sequence=2 ttl=254 time=30 ms
Reply from 192.168.3.1: bytes=56 Sequence=3 ttl=254 time=40 ms
Reply from 192.168.3.1: bytes=56 Sequence=4 ttl=254 time=30 ms
Reply from 192.168.3.1: bytes=56 Sequence=5 ttl=254 time=30 ms
--- 192.168.3.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/32/40 ms
[R1]ping 192.168.5.1
PING 192.168.5.1: 56 data bytes, press CTRL_C to break
Reply from 192.168.5.1: bytes=56 Sequence=1 ttl=254 time=40 ms
Reply from 192.168.5.1: bytes=56 Sequence=2 ttl=254 time=20 ms
Reply from 192.168.5.1: bytes=56 Sequence=3 ttl=254 time=40 ms
Reply from 192.168.5.1: bytes=56 Sequence=4 ttl=254 time=30 ms
Reply from 192.168.5.1: bytes=56 Sequence=5 ttl=254 time=20 ms
--- 192.168.5.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/30/40 ms
[R1]ping 192.168.4.1
PING 192.168.4.1: 56 data bytes, press CTRL_C to break
Reply from 192.168.4.1: bytes=56 Sequence=1 ttl=254 time=30 ms
Reply from 192.168.4.1: bytes=56 Sequence=2 ttl=254 time=30 ms
Reply from 192.168.4.1: bytes=56 Sequence=3 ttl=254 time=30 ms
Reply from 192.168.4.1: bytes=56 Sequence=4 ttl=254 time=30 ms
Reply from 192.168.4.1: bytes=56 Sequence=5 ttl=254 time=30 ms
--- 192.168.4.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/30/30 ms