OSPF 配置实战

简介: 拓扑中的 IP 地址段采用:172.8.AB.X/24其中 AB 为两台路由器编号组合,例如:R2-R3 之间的 AB 为 23,X 为路由器编号,例如 R3 的 X=3R1/R4/R6 之间的网段为:172.8.146.X/24,其中 X 为路由器编号。R4/R5/R6 之间的网段为:172.8.100.X/24,其中 X 为路由器编号。所有路由器都有一个 Loopback 0 接口,地址格式为:X.X.X.X/32,其中 X 为路由器编号。

实验拓扑

IP地址规划

  • 拓扑中的 IP 地址段采用:172.8.AB.X/24
  • 其中 AB 为两台路由器编号组合,例如:R2-R3 之间的 AB 为 23,X 为路由器编号,例如 R3 的 X=3
  • R1/R4/R6 之间的网段为:172.8.146.X/24,其中 X 为路由器编号。
  • R4/R5/R6 之间的网段为:172.8.100.X/24,其中 X 为路由器编号。
  • 所有路由器都有一个 Loopback 0 接口,地址格式为:X.X.X.X/32,其中 X 为路由器编号。
  • 没有特殊要求,不允许使用静态路由。

实验需求

  1. 按照要求配置 IP 地址。
  2. 按照实验拓扑配置一个 OSPF 网络,进程 ID 为 89 ,RID 为 Loopback 0 地址。
  3. R4/R5/R6 相连的三个站点链路 OSPF 网络类型配置成广播型,其中 R5 路由器做为永久性 DR。
  4. 按照图示配置 OSPF 区域,其中 R1/R4/R6 之间的区域要配置成完全末梢区域。
  5. R2 为新并入的站点,由于来不及布线施工而暂时并到 R3 这个站点上,所在区域为 AREA 23,配置使得所有网络可达(采用 ping 测试)。
  6. OSPF 内部的网络希望通过 R5 路由器访问 Internet(假设 R5 和 Internet 连接),配置 R5 使其能够满足需求,只考虑内部 OSPF 的实现。
  7. AREA 0 基于安全的原因配置上 MD5 认证,密码:SPOTO
  8. AREA 146 中,配置 R1 为指定路由器(DR),R4/R6 之间保持 two-way 的邻居关系。
  9. 为了减少网络流量,将 R1 所在的区域汇总成主类网络通告出去。
  10. 由于 R6 与 R5 之间的链路质量较好,适当配置使得 R1 优先选取 R6 访问自身区域除外的外部网络。
  11. 在 AREA 0 以外的所有区域启用 OSPF 明文认证,密码:SPOTO

案例配置思路及检验结果

按照要求配置 IP 地址。

R1:
Router(config)#interface loopback0
Router(config-if)#ip address 1.1.1.1 255.255.255.255
Router(config-if)#no shutdown
Router(config-if)#interface ethernet0/0
Router(config-if)#ip address 172.8.146.1 255.255.255.0
Router(config-if)#no shutdown
R2:
Router(config)#interface loopback0
Router(config-if)#ip address 2.2.2.2 255.255.255.255
Router(config-if)#no shutdown
Router(config-if)#interface ethernet0/0
Router(config-if)#ip address 172.8.23.2 255.255.255.0
Router(config-if)#no shutdown
R3:
Router(config)#interface loopback 0 
Router(config-if)#ip address 3.3.3.3 255.255.255.255
Router(config-if)#no shutdown
Router(config-if)#interface ethernet0/0
Router(config-if)#ip address 172.8.23.3 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#interface interface ethernet0/1
Router(config-if)#ip address 172.8.35.3 255.255.255.0
Router(config-if)#no shutdown
R4:
Router(config)#interface loopback0
Router(config-if)#ip address 4.4.4.4 255.255.255.255 
Router(config-if)#no shutdown
Router(config-if)#interface ethernet0/1
Router(config-if)#ip address 172.8.100.4 255.255.255.0 
Router(config-if)#no shutdown
Router(config-if)#interface ethernet 0/2
Router(config-if)#ip address 172.8.146.4 255.255.255.0
Router(config-if)#no shutdown
R5:
Router(config)#interface Loopback0
Router(config-if)#ip address 5.5.5.5 255.255.255.255
Router(config-if)#no shutdown
Router(config-if)#interface Ethernet0/0
Router(config-if)#ip address 172.8.100.5 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#interface Ethernet0/1
Router(config-if)#ip address 172.8.35.5 255.255.255.0
Router(config-if)no shutdown
R6:
Router(config)#interface loopback 0
Router(config-if)#ip address 6.6.6.6 255.255.255.255
Router(config-if)#no shutdown
Router(config-if)#interface ethernet0/0
Router(config-if)#ip address 172.8.146.6 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#interface ethernet0/1
Router(config-if)#ip address 172.8.100.6 255.255.255.0
Router(config-if)#no shutdown


按照实验拓扑配置一个 OSPF 网络,进程 ID 为 89 ,RID 为 Loopback 0 地址。

R1:
Router(config)#router ospf 89
Router(config-router)#router-id 1.1.1.1 
Router(config-router)#network 172.8.146.1 0.0.0.0 area 146
Router(config-router)#network 1.1.1.1 0.0.0.0 area 146
R2:
Router(config)#router ospf 89
Router(config-router)#router-id 2.2.2.2 
Router(config-router)#network 172.8.23.2 0.0.0.0 area 23
Router(config-router)#network 2.2.2.2 0.0.0.0 area 23
R3:
Router(config)#router ospf 89
Router(config-router)#router-id 3.3.3.3 
Router(config-router)#network 172.8.23.3 0.0.0.0 area 23
Router(config-router)#network 172.8.35.3 0.0.0.0 area 35
Router(config-router)#network 3.3.3.3 0.0.0.0 area 35
R4:
Router(config)#router ospf 89
Router(config-router)#router-id 4.4.4.4
Router(config-router)#network 172.8.100.4 0.0.0.0 area 0
Router(config-router)#network 172.8.146.4 0.0.0.0 area 146
Router(config-router)#network 4.4.4.4 0.0.0.0 area 0
R5:
Router(config)#router ospf 89
Router(config-router)#router-id 5.5.5.5 
Router(config-router)#network 172.8.35.5 0.0.0.0 area 35
Router(config-router)#network 172.8.100.5 0.0.0.0 area 0
Router(config-router)#network 5.5.5.5 0.0.0.0 area 0
R6:
Router(config)#router ospf 89
Router(config-router)#router-id 6.6.6.6
Router(config-router)#network 172.8.100.6 0.0.0.0 area 0
Router(config-router)#network 172.8.146.6 0.0.0.0 area 146
Router(config-router)#network 6.6.6.6 0.0.0.0 area 0


R4/R5/R6 相连的三个站点链路 OSPF 网络类型配置成广播型,其中 R5 路由器做为永久性 DR。

在以太网中,默认的网络类型即为广播型。想让 R5 永久成为 DR,需要将 R4 和R6 的接口优先级改为 0,不允许他们参与选举。

R4:
Router(config)#interface ethernet0/1
Router(config-if)#ip ospf priority 0
R6:
Router(config)#interface ethernet0/1
Router(config-if)#ip ospf priority 0


效果检查

按照图示配置 OSPF 区域,其中 R1/R4/R6 之间的区域要配置成完全末梢区域。

R4:
Router(config)#router ospf 89
Router(config-router)#area 146 stub no-summary
R6:
Router(config)#router ospf 89
Router(config-router)#area 146 stub no-summary
R1:
Router(config)#router ospf 89
Router(config-router)#area 146 stub


R2 为新并入的站点,由于来不及布线施工而暂时并到 R3 这个站点上,所在区域为 AREA 23,配置使得所有网络可达(采用 ping 测试)。

由于 AREA 23 没有与 AREA 0 相连,需要使用虚链路来完成。

R3:
Router(config)#router ospf 89
Router(config-router)#area 35 virtual-link 5.5.5.5
R5:
Router(config)#router ospf 89
Router(config-router)#area 35 virtual-link 3.3.3.3


效果验证

OSPF 内部的网络希望通过 R5 路由器访问 Internet(假设 R5 和 Internet 连接),配置 R5 使其能够满足需求,只考虑内部 OSPF 的实现。

Router(config)#router ospf 89
Router(config-router)#default-information originate always


AREA 0 基于安全的原因配置上 MD5 认证,密码:SPOTO

R5:
Router(config)#router ospf 89
Router(config-router)#area 0 authentication message-digest
Router(config-router)#$tual-link 3.3.3.3 message-digese-key 1 md5 SPOTO      
area 35 virtual-link 3.3.3.3 message-digest-key 1 md5 SPOTO
Router(config)#interface ethernet 0/0
Router(config-if)#ip ospf message-digest-key 1 md5 SPOTO
R3:
Router(config)#router ospf 89
Router(config-router)#area 0 authentication message-digest
Router(config-router)#$tual-link 5.5.5.5 message-digest-key 1 md5 SPOTO 
R4:
Router(config)#router ospf 89
Router(config-router)#area 0 authentication message-digest
Router(config-router)#interface ethernet0/1
Router(config-if)#ip ospf message-digest-key 1 md5 SPOTO
R6:
Router(config)#router ospf 89
Router(config-router)#area 0 authentication message-digest
Router(config-router)#interface ethernet0/1
Router(config-if)#ip ospf message-digest-key 1 md5 SPOTO


AREA 146 中,配置 R1 为指定路由器(DR),R4/R6 之间保持 two-way 的邻居关系。

R4:
Router(config)#interface ethernet0/2
Router(config-if)#ip ospf priority 0
R6:
Router(config)#interface ethernet0/0
Router(config-if)#ip ospf priority 0


为了减少网络流量,将 R1 所在的区域汇总成主类网络通告出去。

R4、R6:
Router(config)#router ospf 89
Router(config-router)#area 146 range 172.8.0.0 255.255.0.0

由于 R6 与 R5 之间的链路质量较好,适当配置使得 R1 优先选取 R6 访问自身区域除外的外部网络。

Router(config)#router ospf 89
Router(config-router)#area 146 default-cost 100

在 AREA 0 以外的所有区域启用 OSPF 明文认证,密码:SPOTO

R1:
Router(config)#router ospf 89
Router(config-router)#area 146 authentication 
Router(config-router)#interface ethernet0/0
Router(config-if)#ip ospf authentication-key SPOTO
R4:
Router(config)#router ospf 89
Router(config-router)#area 146 authentication 
Router(config-router)#interface ethernet0/2
Router(config-if)#ip ospf authentication-key SPOTO
R6:
Router(config)#router ospf 89
Router(config-router)#area 146 authentication
Router(config-router)#interface ethernet0/0
Router(config-if)#ip ospf authentication-key SPOTO
R5:
Router(config-router)#router ospf 89
Router(config-router)#area 35 authentication 
Router(config-router)#interface ethernet0/1
Router(config-if)#ip ospf authentication-key SPOTO
R3:
Router(config)#router ospf 89
Router(config-router)#area 23 authentication
Router(config-router)#area 35 authentication
Router(config-router)#interface ethernet0/1
Router(config-if)#ip ospf authentication-key SPOTO
Router(config-if)#interface ethernet0/0
Router(config-if)#ip ospf authentication-key SPOTO
R2:
Router(config)#router ospf 89
Router(config-router)#area 23 authentication
Router(config-router)#interface ethernet0/0
Router(config-if)#ip ospf authentication-key SPOTO


验证:

目录
相关文章
|
11月前
|
负载均衡 网络协议 算法
第二章OSPF配置
第二章OSPF配置
|
网络协议 网络架构
OSPF高级配置
OSPF高级配置
114 0
OSPF高级配置
|
网络协议 算法 数据库
OSPF原理
OSPF原理
149 0
|
网络协议 数据库 网络架构
OSPF路由协议-高级配置——OSPF路由高级应用
一OSPF重分发路由 1.重分发到OSPF域中路由的路径类型 类型1的外部路径(Type 1 external path, E1) 类型2的外部路径(Type 2 external path, E2) 2.路由器A有两条到达外部目的网络10.1.2.0的路径 E1类型 1.路径A-B-D的代价是25(20+5) (优先) 2.路径A-C-D代价为48(18+30) E2类型 1.路径A-B-D的代价是20 2.路径A-C-D的代价为18 (优先)
186 0
OSPF路由协议-高级配置——OSPF路由高级应用
|
网络协议 算法 数据库
OSPF动态路由协议基础知识
OSPF动态路由协议基础知识
155 1
OSPF动态路由协议基础知识
|
网络协议
配置OSPF
配置OSPF
75 0
配置OSPF
|
网络协议 算法 网络架构
OSPF高级配置——学习OSPF路由协议的高级应用
在一个大型的网络中会存在很多问题,如新建区域没有和骨干区域相连,路由条目过多,L.SDB过大,OSPF和其他路由协议之间如何通信等问题,需要进一步解决和优化。通过本章的学习可以解 决上面提到的OSPF网络中存在的一些问题,本章将介绍OSPF路由协议的NSSA区域的概念和配置以及一些OSPF路由协议的高级应用(路由重分发、地址汇总、虚链路等)的原理和配置。
152 0
OSPF高级配置——学习OSPF路由协议的高级应用
|
网络协议 网络架构
OSPF路由协议基础(OSPF基本配置)
OSPF路由协议基础(OSPF基本配置)
542 0
OSPF路由协议基础(OSPF基本配置)
|
网络协议 数据库 网络架构