OSPF 配置实战

16 篇文章 1 订阅

实验拓扑

在这里插入图片描述

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

案例配置思路及检验结果

  1. 按照要求配置 IP 地址。
R1Router(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
R2Router(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
R3Router(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
R4Router(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
R6Router(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
  1. 按照实验拓扑配置一个 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 
  1. R4/R5/R6 相连的三个站点链路 OSPF 网络类型配置成广播型,其中 R5 路由器做为永久性 DR。

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

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

效果检查
在这里插入图片描述

  1. 按照图示配置 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
  1. 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

效果验证
在这里插入图片描述

  1. OSPF 内部的网络希望通过 R5 路由器访问 Internet(假设 R5 和 Internet 连接),配置 R5 使其能够满足需求,只考虑内部 OSPF 的实现。
Router(config)#router ospf 89
Router(config-router)#default-information originate always
  1. AREA 0 基于安全的原因配置上 MD5 认证,密码:SPOTO
R5Router(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
R3Router(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 
R4Router(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
R6Router(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
  1. AREA 146 中,配置 R1 为指定路由器(DR),R4/R6 之间保持 two-way 的邻居关系。
R4Router(config)#interface ethernet0/2
Router(config-if)#ip ospf priority 0
R6Router(config)#interface ethernet0/0
Router(config-if)#ip ospf priority 0
  1. 为了减少网络流量,将 R1 所在的区域汇总成主类网络通告出去。
R4R6:
Router(config)#router ospf 89
Router(config-router)#area 146 range 172.8.0.0 255.255.0.0
  1. 由于 R6 与 R5 之间的链路质量较好,适当配置使得 R1 优先选取 R6 访问自身区域除外的外部网络。
Router(config)#router ospf 89
Router(config-router)#area 146 default-cost 100
  1. 在 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

验证:
在这里插入图片描述

  • 8
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

牧鸯人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值