一、分析要求
- 自行定义公网网段和私有网段,ISP设备仅配置IP地址
- R1/R4/R5构建
Full-Mesh
结构 - R1/R2/R3构建
Hub-Spoke
结构,R1为NHS - 除ISP设备,其余路由器运行OSPF
二、实施过程
1. 配置IP及环回地址
R1
[R1]int g 0/0/0
[R1-GigabitEthernet0/0/0]ip add 20.0.0.1 24
[R1-GigabitEthernet0/0/0]int g 0/0/1
[R1-GigabitEthernet0/0/1]ip add 21.0.0.1 24
[R1-GigabitEthernet0/0/1]int l 0
[R1-LoopBack0]ip add 192.168.1.1 24
R2
[R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R2-GigabitEthernet0/0/0]int l 0
[R2-LoopBack0]ip add 192.168.2.1 24
R3
[R3]int g 0/0/0
[R3-GigabitEthernet0/0/0]ip add 13.0.0.1 24
[R3-GigabitEthernet0/0/0]int l 0
[R3-LoopBack0]ip add 192.168.3.1 24
R4
[R4]int g 0/0/0
[R4-GigabitEthernet0/0/0]ip add 14.0.0.1 24
[R4-GigabitEthernet0/0/0]int l 0
[R4-LoopBack0]ip add 192.168.4.1 24
R5
[R5]int g 0/0/0
[R5-GigabitEthernet0/0/0]ip add 15.0.0.1 24
[R5-GigabitEthernet0/0/0]int l 0
[R5-LoopBack0]ip add 192.168.5.1 24
R6
[R6]int g 0/0/0
[R6-GigabitEthernet0/0/0]ip add 20.0.0.2 24
[R6-GigabitEthernet0/0/0]int g 0/0/1
[R6-GigabitEthernet0/0/1]ip add 21.0.0.2 24
[R6-GigabitEthernet0/0/1]int g 2/0/0
[R6-GigabitEthernet2/0/0]ip add 12.0.0.2 24
[R6-GigabitEthernet2/0/0]int g 3/0/0
[R6-GigabitEthernet3/0/0]ip add 13.0.0.2 24
[R6-GigabitEthernet3/0/0]int g 4/0/0
[R6-GigabitEthernet4/0/0]ip add 14.0.0.2 24
[R6-GigabitEthernet4/0/0]int g 0/0/2
[R6-GigabitEthernet0/0/2]ip add 15.0.0.2 24
测试
2. 搭建Hub-Spoke结构
- R1为中心站点,R2、R3为分支
- 隧道接口网段定义为192.168.10.0/24
中心R1配置
[R1]int t 0/0/0 //创建隧道接口
[R1-Tunnel0/0/0]ip add 192.168.10.1 24 //配置接口IP
[R1-Tunnel0/0/0]tunnel-protocol gre p2mp //定义封装方式P2MP
[R1-Tunnel0/0/0]source 20.0.0.1 //定义封装内容,该IP不可变
[R1-Tunnel0/0/0]nhrp network-id 100 //创建域,id为100
分支R2配置
[R2]int t 0/0/0
[R2-Tunnel0/0/0]ip add 192.168.10.2 24
[R2-Tunnel0/0/0]tunnel-protocol gre p2mp
[R2-Tunnel0/0/0]source GigabitEthernet 0/0/0 //使用出接口,因为IP地址可变
[R2-Tunnel0/0/0]nhrp network-id 100 //加入域
[R2-Tunnel0/0/0]nhrp entry 192.168.10.1 20.0.0.1 register //向中心注册
分支R3配置
[R3]int t 0/0/0
[R3-Tunnel0/0/0]ip add 192.168.10.3 24
[R3-Tunnel0/0/0]tunnel-protocol gre p2mp
[R3-Tunnel0/0/0]source GigabitEthernet 0/0/0
[R3-Tunnel0/0/0]nhrp network-id 100
[R3-Tunnel0/0/0]nhrp entry 192.168.10.1 20.0.0.1 register
添加缺省路由,确保公网畅通
[R1]ip route-static 0.0.0.0 0 20.0.0.2
[R2]ip route-static 0.0.0.0 0 12.0.0.2
[R3]ip route-static 0.0.0.0 0 13.0.0.2
开启伪广播
[R1-Tunnel0/0/0]nhrp entry multicast dynamic
更改接口类
型为P2MP
[R1-Tunnel0/0/0]ospf network-type p2mp
[R2-Tunnel0/0/0]ospf network-type p2mp
[R3-Tunnel0/0/0]ospf network-type p2mp
查看R1 ospf 邻居表
3. 搭建Full-Mesh结构
R1、R4、R5搭建
R1配置
[R1]int t 0/0/1
[R1-Tunnel0/0/1]ip add 192.168.15.1 24
[R1-Tunnel0/0/1]tunnel-protocol gre p2mp
[R1-Tunnel0/0/1]source 21.0.0.1
[R1-Tunnel0/0/1]nhrp network-id 110
R4配置
[R4]int t 0/0/1
[R4-Tunnel0/0/1]ip add 192.168.15.4 24
[R4-Tunnel0/0/1]tunnel-protocol gre p2mp
[R4-Tunnel0/0/1]source 14.0.0.1 //full-mesh中接口ip不可变,分支也可以直接配ip
[R4-Tunnel0/0/1]nhrp network-id 110
[R4-Tunnel0/0/1]nhrp entry 192.168.15.1 21.0.0.1 register
[R4-Tunnel0/0/1]nhrp entry 192.168.15.5 15.0.0.1 register //向其他所有设备注册
R5配置
[R5]int t 0/0/1
[R5-Tunnel0/0/1]ip add 192.168.15.5 24
[R5-Tunnel0/0/1]tunnel-protocol gre p2mp
[R5-Tunnel0/0/1]source 15.0.0.1
[R5-Tunnel0/0/1]nhrp network-id 110
[R5-Tunnel0/0/1]nhrp entry 192.168.15.1 21.0.0.1 register
添加缺省路由,确保公网畅通
[R1]ip route-static 0.0.0.0 0 21.0.0.2
[R4]ip route-static 0.0.0.0 0 14.0.0.2
[R5]ip route-static 0.0.0.0 0 15.0.0.2
开启伪广播
[R1-Tunnel0/0/1]nhrp entry multicast dynamic
[R4-Tunnel0/0/1]nhrp entry multicast dynamic
[R5-Tunnel0/0/1]nhrp entry multicast dynamic
更改接口类型
[R1-Tunnel0/0/1]ospf network-type broadcast
[R4-Tunnel0/0/1]ospf network-type broadcast
[R5-Tunnel0/0/1]ospf network-type broadcast
查看R1 ospf 邻居表
4. 运行OSPF协议
宣告私网网段和隧道网段
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]a 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 192.168.10.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 192.168.15.0 0.0.0.255
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]a 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 192.168.10.0 0.0.0.255
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]a 0
[R3-ospf-1-area-0.0.0.0]network 192.168.3.1 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 192.168.10.0 0.0.0.255
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]a 0
[R4-ospf-1-area-0.0.0.0]network 192.168.4.1 0.0.0.0
[R4-ospf-1-area-0.0.0.0]network 192.168.15.0 0.0.0.255
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]a 0
[R5-ospf-1-area-0.0.0.0]network 192.168.5.1 0.0.0.0
[R5-ospf-1-area-0.0.0.0]network 192.168.15.0 0.0.0.255
查看OSPF路由表
R1
R2
R3
R4
R5