【HCIP】OSPF综合实验报告

一、分析要求

  1. R4为ISP,直连设备间使用公网网段
  2. R3、R5、R6、R7为MGRE环境,R3为NHS
  3. 合理划分172.16.0.0/16网段
  4. 做NAT配置使私网能够访问R4环回
  5. ospf优化(汇总和特殊区域),减少计时器时间加快收敛,设备之间做认证保证更新安全。
  6. 除ISP,其余设备运行ospf,使得全网可达

二、操作过程

1. 划分IP地址

2. 配置IP地址及环回地址

R1

复制代码
[R1]int g 0/0/0
[R1-GigabitEthernet0/0/0]ip add 172.16.33.1 29
[R1-GigabitEthernet0/0/0]int l 0
[R1-LoopBack0]ip add 172.16.34.1 24

R2

复制代码
[R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip add 172.16.33.2 29
[R2-GigabitEthernet0/0/0]int l 0
[R2-LoopBack0]ip add 172.16.35.1 24

R3

复制代码
[R3]int g 0/0/0
[R3-GigabitEthernet0/0/0]ip add 172.16.33.3 29
[R3-GigabitEthernet0/0/0]int l 0 
[R3-LoopBack0]ip add 172.16.36.1 24
[R3-LoopBack0]int s 4/0/0
[R3-Serial4/0/0]ip add 34.0.0.1 24

R4

复制代码
[R4]int s 4/0/0
[R4-Serial4/0/0]ip add 34.0.0.2 24
[R4-Serial4/0/0]int s 4/0/1 
[R4-Serial4/0/1]ip add 45.0.0.2 24
[R4-Serial4/0/1]int s 3/0/0
[R4-Serial3/0/0]ip add 46.0.0.2 24
[R4-Serial3/0/0]int g 0/0/0
[R4-GigabitEthernet0/0/0]ip add 47.0.0.2 24
[R4-GigabitEthernet0/0/0]int l 0
[R4-LoopBack0]ip add 4.4.4.4 24

R5

复制代码
[R5]int s 4/0/0
[R5-Serial4/0/0]ip add 45.0.0.1 24
[R5-Serial4/0/0]int l 0
[R5-LoopBack0]ip add 172.16.2.1 24

R6

复制代码
[R6]int s 4/0/0
[R6-Serial4/0/0]ip add 46.0.0.1 24
[R6-Serial4/0/0]int g 0/0/0
[R6-GigabitEthernet0/0/0]ip add 172.16.65.1 29
[R6-GigabitEthernet0/0/0]int l 0
[R6-LoopBack0]ip add 172.16.3.1 24

R7

复制代码
[R7]int g 0/0/0
[R7-GigabitEthernet0/0/0]ip add 47.0.0.1 24
[R7-GigabitEthernet0/0/0]int g 0/0/1
[R7-GigabitEthernet0/0/1]ip add 172.16.97.1 29
[R7-GigabitEthernet0/0/1]int l 0
[R7-LoopBack0]ip add 172.16.4.1 24

R8

复制代码
[R8]int g 0/0/0
[R8-GigabitEthernet0/0/0]ip add 172.16.97.2 29
[R8-GigabitEthernet0/0/0]int g 0/0/1
[R8-GigabitEthernet0/0/1]ip add 172.16.97.9 29
[R8-GigabitEthernet0/0/1]int l 0
[R8-LoopBack0]ip add 172.16.98.1 24

R9

复制代码
[R9]int g 0/00/0
[R9-GigabitEthernet0/0/0]ip add 172.16.97.10 29
[R9-GigabitEthernet0/0/0]int g 0/0/1
[R9-GigabitEthernet0/0/1]ip add 172.16.129.1 29
[R9-GigabitEthernet0/0/1]int l 0
[R9-LoopBack0]ip add 172.16.130.1 24

R10

复制代码
[R10]int g 0/0/0
[R10-GigabitEthernet0/0/0]ip add 172.16.129.2 29
[R10-GigabitEthernet0/0/0]int l0
[R10-LoopBack0]ip add 172.16.131.1 24

R11

复制代码
[R11]int g 0/0/0
[R11-GigabitEthernet0/0/0]ip add 172.16.65.2 29
[R11-GigabitEthernet0/0/0]int g 0/0/1
[R11-GigabitEthernet0/0/1]ip add 172.16.65.9 29
[R11-GigabitEthernet0/0/1]int l 0
[R11-LoopBack0]ip add 172.16.66.1 24

R12

复制代码
[R12] int g 0/0/0
[R12-GigabitEthernet0/0/0]ip add 172.16.65.10 29
[R12-GigabitEthernet0/0/0]int l 0
[R12-LoopBack0]ip add 172.16.162.1 24
[R12-LoopBack0]int l 1
[R12-LoopBack1]ip add 172.16.163.1 24

缺省路由

复制代码
[R3]ip route-static 0.0.0.0 0 34.0.0.2
[R5]ip route-static 0.0.0.0 0 45.0.0.2
[R6]ip route-static 0.0.0.0 0 46.0.0.2
[R7]ip route-static 0.0.0.0 0 47.0.0.2

测试

3. 运行OSPF

R1

复制代码
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]a 1
[R1-ospf-1-area-0.0.0.1]network 172.16.33.1 0.0.0.0
[R1-ospf-1-area-0.0.0.1]network 172.16.34.1 0.0.0.0

R2

复制代码
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]a 1
[R2-ospf-1-area-0.0.0.1]network 172.16.33.2 0.0.0.0
[R2-ospf-1-area-0.0.0.1]network 172.16.35.1 0.0.0.0

R3

复制代码
[R3]ospf 1 router-id 3.3.3.3 
[R3-ospf-1]a 1
[R3-ospf-1-area-0.0.0.1]network 172.16.33.3 0.0.0.0
[R3-ospf-1-area-0.0.0.1]network 172.16.36.1 0.0.0.0

R5

复制代码
[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.2.1 0.0.0.0

R6

复制代码
[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.3.1 0.0.0.0
[R6-ospf-1-area-0.0.0.0]a 2
[R6-ospf-1-area-0.0.0.2]network 172.16.65.1 0.0.0.0

R7

复制代码
[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.4.1 0.0.0.0
[R7-ospf-1-area-0.0.0.0]a 3
[R7-ospf-1-area-0.0.0.3]network 172.16.97.1 0.0.0.0

R8

复制代码
[R8]ospf 1 router-id 8.8.8.8
[R8-ospf-1-area-0.0.0.1]a 3
[R8-ospf-1-area-0.0.0.3]network 172.16.97.2 0.0.0.0
[R8-ospf-1-area-0.0.0.3]network 172.16.97.9 0.0.0.0
[R8-ospf-1-area-0.0.0.3]network 172.16.98.1 0.0.0.0

R9

复制代码
[R9]ospf 1 router-id 9.9.9.9
[R9-ospf-1]a 3
[R9-ospf-1-area-0.0.0.3]network 172.16.97.10 0.0.0.0
[R9]ospf 2 router-id 9.9.9.9
[R9-ospf-2]a 4
[R9-ospf-2-area-0.0.0.4]network 172.16.129.1 0.0.0.0
[R9-ospf-2-area-0.0.0.4]network 172.16.130.1 0.0.0.0

R10

复制代码
[R10]ospf 1 router-id 10.10.10.10
[R10-ospf-1]a 4
[R10-ospf-1-area-0.0.0.4]network 172.16.129.2 0.0.0.0
[R10-ospf-1-area-0.0.0.4]network 172.16.131.1 0.0.0.0

R11

复制代码
[R11]ospf 1 router-id 11.11.11.11
[R11-ospf-1]a 2
[R11-ospf-1-area-0.0.0.2]network 172.16.65.2 0.0.0.0
[R11-ospf-1-area-0.0.0.2]network 172.16.65.9 0.0.0.0
[R11-ospf-1-area-0.0.0.2]network 172.16.66.1 0.0.0.0

R12

复制代码
[R12]ospf 1 router-id 12.12.12.12
[R12-ospf-1]a 2
[R12-ospf-1-area-0.0.0.2]network 172.16.65.10 0.0.0.0
[R12]rip 
[R12-rip-1]v 2
[R12-rip-1]undo summary 
[R12-rip-1]network 172.16.0.0

4. 搭建MGRE环境

R3中心配置

复制代码
[R3]int t 0/0/0
[R3-Tunnel0/0/0]ip add 172.16.1.1 29
[R3-Tunnel0/0/0]tunnel-protocol gre p2mp 	
[R3-Tunnel0/0/0]source 34.0.0.1
[R3-Tunnel0/0/0]nhrp network-id 100
[R3-Tunnel0/0/0]nhrp entry multicast dynamic

R5分支配置

复制代码
[R5]int t 0/0/0
[R5-Tunnel0/0/0]ip add 172.16.1.2 29
[R5-Tunnel0/0/0]tunnel-protocol gre p2mp 
[R5-Tunnel0/0/0]source Serial 4/0/0
[R5-Tunnel0/0/0]nhrp network-id 100
[R5-Tunnel0/0/0]nhrp entry 172.16.1.1 34.0.0.1 register 

R6分支配置

复制代码
[R6]int t 0/0/0
[R6-Tunnel0/0/0]ip add 172.16.1.3 29
[R6-Tunnel0/0/0]tunnel-protocol gre p2mp 	
[R6-Tunnel0/0/0]source s 4/0/0
[R6-Tunnel0/0/0]nhrp network-id 100
[R6-Tunnel0/0/0]nhrp entry 172.16.1.1 34.0.0.1 register 

R7分支配置

复制代码
[R7]int t 0/0/0
[R7-Tunnel0/0/0]ip add 172.16.1.4 29
[R7-Tunnel0/0/0]tunnel-protocol gre p2mp 
[R7-Tunnel0/0/0]source g 0/0/0
[R7-Tunnel0/0/0]nhrp network-id 100
[R7-Tunnel0/0/0]nhrp entry 172.16.1.1 34.0.0.1 register 

将tunnel隧道网段宣告进OSPF

复制代码
[R3-ospf-1-area-0.0.0.0]network 172.16.1.1 0.0.0.0
[R5-ospf-1-area-0.0.0.0]network 172.16.1.2 0.0.0.0
[R6-ospf-1-area-0.0.0.0]network 172.16.1.3 0.0.0.0
[R7-ospf-1-area-0.0.0.0]network 172.16.1.4 0.0.0.0

修改Tunnel隧道接口网络类型为P2MP,避免DR/BDR选举,加快收敛

复制代码
[R3-Tunnel0/0/0]ospf network-type p2mp
[R5-Tunnel0/0/0]ospf network-type p2mp
[R6-Tunnel0/0/0]ospf network-type p2mp
[R7-Tunnel0/0/0]ospf network-type p2mp

查看NHRP邻居表及OSPF邻居表

查看区域0的路由表

5. 重发布

将rip的路由导入

复制代码
[R12-ospf-1]import-route rip 1

将area 4的路由导入

复制代码
[R9-ospf-1]import-route ospf 2

[R10]ip route-static 0.0.0.0 0 172.16.129.1

查看area 0的路由表

测试

6. 优化

汇总

复制代码
[R3-ospf-1-area-0.0.0.1]abr-summary 172.16.32.0 255.255.224.0
[R6-ospf-1-area-0.0.0.2]abr-summary 172.16.64.0 255.255.224.0
[R7-ospf-1-area-0.0.0.3]abr-summary 172.16.96.0 255.255.224.0
[R9-ospf-1]asbr-summary 172.16.128.0 255.255.224.0
[R12-ospf-1]asbr-summary 172.16.160.0 255.255.224.0

area 1 --- 完全stub区域

复制代码
[R1-ospf-1-area-0.0.0.1]stub
[R2-ospf-1-area-0.0.0.1]stub
[R3-ospf-1-area-0.0.0.1]stub no-summary

area 2 --- 完全nssa区域

复制代码
[R6-ospf-1-area-0.0.0.2]nssa no-summary
[R11-ospf-1-area-0.0.0.2]nssa
[R12-ospf-1-area-0.0.0.2]nssa

area 3 --- 完全的nssa区域

复制代码
[R7-ospf-1-area-0.0.0.3]nssa no-summary
[R8-ospf-1-area-0.0.0.3]nssa
[R9-ospf-1-area-0.0.0.3]nssa

7. 加快收敛

修改接口类型

复制代码
[R6-GigabitEthernet0/0/0]ospf network-type p2p

[R7-GigabitEthernet0/0/1]ospf network-type p2p

[R8-GigabitEthernet0/0/0]ospf network-type p2p
[R8-GigabitEthernet0/0/1]ospf network-type p2p

[R9-GigabitEthernet0/0/0]ospf network-type p2p
[R9-GigabitEthernet0/0/1]ospf network-type p2p

[R10-GigabitEthernet0/0/0]ospf network-type p2p

[R11-GigabitEthernet0/0/0]ospf network-type p2p
[R11-GigabitEthernet0/0/1]ospf network-type p2p

[R12-GigabitEthernet0/0/0]ospf network-type p2p

修改计时器

复制代码
[R3-Tunnel0/0/0]ospf timer hello 10 
[R5-Tunnel0/0/0]ospf timer hello 10
[R6-Tunnel0/0/0]ospf timer hello 10
[R7-Tunnel0/0/0]ospf timer hello 10

8. 更新安全

area 1

复制代码
[R1-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 123456
[R2-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 123456
[R3-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 123456

Tunnel

复制代码
[R3-Tunnel0/0/0]ospf authentication-mode md5 1 cipher 3567
[R5-Tunnel0/0/0]ospf authentication-mode md5 1 cipher 3567
[R6-Tunnel0/0/0]ospf authentication-mode md5 1 cipher 3567
[R7-Tunnel0/0/0]ospf authentication-mode md5 1 cipher 3567

area 2

复制代码
[R6-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 61112
[R11-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 61112
[R11-GigabitEthernet0/0/1]ospf authentication-mode md5 1 cipher 61112
[R12-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 61112

area 3

复制代码
[R7-GigabitEthernet0/0/1]ospf authentication-mode md5 1 cipher 789
[R8-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 789
[R8-GigabitEthernet0/0/1]ospf authentication-mode md5 1 cipher 789
[R9-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 789

area 4

复制代码
[R9-GigabitEthernet0/0/1]ospf authentication-mode md5 1 cipher 910
[R10-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 910

9. 空接口

复制代码
[R3]ip route-static 172.16.32.0 19 NULL 0
[R6]ip route-static 172.16.64.0 19 NULL 0
[R7]ip route-static 172.16.96.0 19 NULL 0
[R9]ip route-static 172.16.128.0 19 NULL 0
[R12]ip route-static 172.16.160.0 19 NULL 0

10. NAT配置

R3配置

复制代码
[R3]acl 2000
[R3-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R3-acl-basic-2000]q
[R3]int s 4/0/0
[R3-Serial4/0/0]nat outbound 2000

私网pingR4环回(R1)

R6配置

复制代码
[R6]acl 2000
[R6-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R6-acl-basic-2000]q
[R6]int s 4/0/0
[R6-Serial4/0/0]nat outbound 2000

私网pingR4环回(R11)

R7配置

复制代码
[R7]acl 2000
[R7-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R7-acl-basic-2000]q
[R7]int g 0/0/0
[R7-GigabitEthernet0/0/0]nat outbound 2000

私网pingR4环回(R8)

相关推荐
Xの哲學1 小时前
Linux流量控制: 内核队列的深度剖析
linux·服务器·算法·架构·边缘计算
tuokuac2 小时前
docker中nginx配置报错解决
linux·运维·服务器
掘根2 小时前
【消息队列项目】虚拟机管理实现
网络
Joren的学习记录3 小时前
【Linux运维大神系列】docker详解(四)
linux·运维·docker
老王熬夜敲代码3 小时前
网络中数据传输的具体过程
linux·网络·笔记
Elastic 中国社区官方博客4 小时前
让我们把这个 expense 工具从 n8n 迁移到 Elastic One Workflow
大数据·运维·elasticsearch·搜索引擎·ai·信息可视化·全文检索
汤愈韬4 小时前
TK_网络基础和常见攻击(笔记)
网络·笔记
程序员佳佳4 小时前
2025年大模型终极横评:GPT-5.2、Banana Pro与DeepSeek V3.2实战硬核比拼(附统一接入方案)
服务器·数据库·人工智能·python·gpt·api
( •̀∀•́ )9204 小时前
GitHub Actions SSH 部署密钥
运维·ssh·github
louqle4 小时前
docker基本知识及常用命令汇总
运维·docker·容器