• OSPF 配置实战


    实验拓扑

    在这里插入图片描述

    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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    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
    • 2
    • 3
    • 4
    • 5
    • 6

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

    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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    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
    • 2
    • 3
    • 4
    • 5
    • 6

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

    1. OSPF 内部的网络希望通过 R5 路由器访问 Internet(假设 R5 和 Internet 连接),配置 R5 使其能够满足需求,只考虑内部 OSPF 的实现。
    Router(config)#router ospf 89
    Router(config-router)#default-information originate always
    
    • 1
    • 2
    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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    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
    • 2
    • 3
    • 4
    • 5
    • 6
    1. 为了减少网络流量,将 R1 所在的区域汇总成主类网络通告出去。
    R4R6:
    Router(config)#router ospf 89
    Router(config-router)#area 146 range 172.8.0.0 255.255.0.0
    
    • 1
    • 2
    • 3
    1. 由于 R6 与 R5 之间的链路质量较好,适当配置使得 R1 优先选取 R6 访问自身区域除外的外部网络。
    Router(config)#router ospf 89
    Router(config-router)#area 146 default-cost 100
    
    • 1
    • 2
    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33

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

  • 相关阅读:
    将DataFrame中符合指定条件的数据替换为指定的值:mask()函数
    卷积神经网络(CNN):乳腺癌识别
    双非大学改考408,软件工程专业考研报考人数较少!
    5、乐趣国学—“行有不得,反求诸己。”
    【JavaScript】手撕前端面试题:寄生组合式继承 | 发布订阅模式 | 观察者模式
    BIGEMAP打开多数据格式(AutoCAD shp kml excel、txt、dat)
    [附源码]Python计算机毕业设计SSM旅游服务平台(程序+LW)
    用移动ip的优势
    Nginx反向代理,header参数带下换线(_),导致接口调用不通,丢失header丢失的问题
    [LeetCode周赛复盘] 第 315 场周赛20221016
  • 原文地址:https://blog.csdn.net/m0_61703913/article/details/126909957