Dell Networking SONiC:开放式最短路径优先 (OSPF)

Resumen: 本文介绍了 Dell Networking SONiC 中的开放式最短路径优先 (OSPF)。本文使用的是运行 Dell SONiC 4.1 的交换机。

Este artículo se aplica a Este artículo no se aplica a Este artículo no está vinculado a ningún producto específico. No se identifican todas las versiones del producto en este artículo.

Instrucciones

 
前提条件
标准接口命名用于演示概念。请参阅戴尔文章 202172Dell Networking S 系列:基本接口配置 - SONiC 4.0,了解有关接口命名的更多信息

索引

 

开放式最短路径优先
启用 OSPFv2
在接口
上启用 OSPF配置 OSPF 路由器 ID
配置 OSPF 区域级身份验证类型
配置 OSPF 接口级身份验证类型和密钥
配置 OSPF 被动接口
配置 OSPF 虚拟链路
配置 OSPF 区域快捷方式
配置 OSPF RFC 兼容性
配置 OSPF 邻接日志记录
配置 OSPF LSA 计时器
配置 OSPF SPF 限制计时器
配置 OSPF 最大指标通告
配置 OSPF 路由距离
配置 OSPF 自动成本参考带宽
配置 OSPF 存根区域及其参数
配置 OSPF 区域间摘要路由筛选器
配置 OSPF 路由重新分发
配置 OSPF 默认路由发起

配置 OSPF 接口参数
OSPF 操作数据显示命令
OSPFv2 正常重启

 

开放式最短路径优先

 

开放式最短路径优先协议 (OSPF) 是一种链路状态内部网关路由协议 (IGRP),如RFC2328中所述。

OSPF 在称为链路状态通告 (LSA) 的消息中描述链路状态信息,然后通过称为泛洪的进程传播到链路状态路由域中的所有其他路由器。因此,每个 OSPF 路由器都会构建所有链路状态消息的链路状态数据库 (LSDB)。然后,根据 LSDB 中的此 LSA 集合,每个路由器都可以使用 Edgar Djikstras 最短路径优先算法,根据一些常见指标计算到任何其他路由器的最短路径。

Enterprise SONiC 使用 FRR 软件包来运行路由协议。OSPFv2 也改编自定制的 FRR 软件包。OPSFv2 路由守护程序与其他路由协议守护程序(如 BGP、静态路由)一起驻留在 BGP docker 容器中。

支持的 OSPFv2 功能:

  • 以太网、环回、VLAN 和端口通道 IPv4 接口上的 OSPF 配置
  • 默认和用户定义的 VRF 上的 OSPFv2 配置
  • 多个 OSPF 区域和存根区域
  • Type-1 至 Type-5 LSA 
  • 虚拟链路和被动接口
  • OSPF 接口会话上的 BFD
  • 纯文本和消息摘要 (MD) 密码加密
  • 类型 3 摘要 LSA 前缀筛选和替换
  • 路由重新分布到 OSPFv2,路由类型为 BGP、static、connected、kernel 和 default-route
  • 路由重新分发中基于路由图的过滤
  • OSPF ECMP 路由数
  • 50K 外部路由和 5K 内部路由前缀
 

启用 OSPFv2

通过在 VRF 中配置 OSPF 路由器来启用 OSPFv2。使用此命令可在 VRF 中配置 OSPFv2。配置 OSPF 会将模式更改为 OSPF 路由器配置模式。

要全局启用 OSPF,默认 vrf:
 

DELLSONiC(conf)# router ospf

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(conf)# router ospf


或者启用 OSPF、非默认 vrf:
 

DELLSONiC(conf)# router ospf vrf Vrf-name
 
  • Vrf-name— VRF 名称字符串
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(conf)# router ospf vrf Vrf-blue


查看 OSPF 路由器详细信息:
 

DELLSONiC# show ip ospf
VRF Name: default
 OSPF Routing Process, Router ID: 10.10.201.1
 Supports only single TOS (TOS0) routes
 This implementation conforms to RFC2328
 RFC1583Compatibility flag is disabled
 OpaqueCapability flag is disabled
 Graceful-Restart is disabled
 Initial SPF scheduling delay 0 millisec(s)
 Minimum hold time between consecutive SPFs 50 millisec(s)
 Maximum hold time between consecutive SPFs 5000 millisec(s)
 Hold time multiplier is currently 1
 SPF algorithm last executed 1d2h7m51s ago
 Last SPF duration 23 usecs
 SPF timer is inactive
 LSA minimum interval 5000 msecs
 LSA minimum arrival 1000 msecs
 Write Multiplier set to 20
 Refresh timer 10 secs
 Maximum multiple paths(ECMP) supported  256
 Number of external LSA 0. Checksum Sum 0x00000000
 Number of opaque AS LSA 0. Checksum Sum 0x00000000
 Number of areas attached to this router: 1
Area ID: 0.0.0.0 (Backbone)
   Number of interfaces in this area: Total: 1 , Active: 1
   Number of fully adjacent neighbors in this area: 1
   Area has no authentication
   SPF algorithm executed 4 times
   Number of LSA 3
   Number of router LSA 2. Checksum Sum 0x0000ec6e
   Number of network LSA 1. Checksum Sum 0x00001a25
   Number of summary LSA 0. Checksum Sum 0x00000000
   Number of ASBR summary LSA 0. Checksum Sum 0x00000000
   Number of NSSA LSA 0. Checksum Sum 0x00000000
   Number of opaque link LSA 0. Checksum Sum 0x00000000
   Number of opaque area LSA 0. Checksum Sum 0x00000000 DELLSONiC# show ip ospf vrf Vrf-Blue
VRF Name: Vrf-Blue
 OSPF Routing Process, Router ID: 0.0.0.0
 Supports only single TOS (TOS0) routes
 This implementation conforms to RFC2328
 RFC1583Compatibility flag is disabled
 OpaqueCapability flag is disabled
{output truncated}


在接口上启用 OSPF


在接口上启用 OSPF 之前,请为 IPv4 接口配置 IP 地址,并将该接口绑定到所需的 VRF。要在 IPv4 接口上启用 OSPF,您必须将 OSPF 区域 ID 与接口关联。可以在以太网、VLAN、端口通道和环回接口上启用 OSPF。

通过在连接两个 OSPF 路由器的接口上启用 OSPF,在两个 OSPF 路由器之间启用 OSPF 会话。此类连接接口应位于配置 OSPF 路由器的 VRF 内,并且应属于同一 Area-ID。

使用 interface mode 命令在 IPv4 接口上启用或禁用 OSPF。区域 ID 可以是任何 32 位无符号整数、十进制格式或点分 Ipv4 格式。

使用以下两种配置类型在接口上启用 OSPF:

通过在接口配置模式下配置 OSPF 区域:
 
DELLSONiC(config-if-Vlan100)# ip ospf area area-id
 
  • area-id - 十进制或虚线格式的 OSPF 区域 ID - A.B.C.D 或 0..4294967295


示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# interface Vlan 100
DELLSONiC(config-if-Vlan100)# ip ospf area 0
or
DELLSONiC(config-if-Vlan100)# ip ospf area 0.0.0.0

通过在 OSPFv2 路由器配置模式下将接口的网络地址绑定或关联到 OSPF 区域:
 
提醒:使用网络命令将接口关联到 OSPF 区域时,接口命令中的 IPv4 地址前缀长度必须等于或大于网络语句中的前缀长度(即,较小的网络)。
 
DELLSONiC(config-router-ospf)# network network-prefix area area-id
 
  • network-prefix - A.B.C.D/mask
  • area-id - 十进制或虚线格式的 OSPF 区域 ID - A.B.C.D 或 0..4294967295

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# network 10.10.150.0/24 area 0.0.0.0
or
DELLSONiC(config-router-ospf)# network 10.10.150.0/24 area 0

在 VRF 中,用户应使用上述配置类型之一,即 VRF 中一次不允许同时使用这两种配置类型配置。
 

示例:

 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# interface Vlan 100
DELLSONiC(config-if-Vlan100)# ip vrf forwarding Vrf-Blue
DELLSONiC(config-if-Vlan100)# ip ospf area 0
or
DELLSONiC(config-if-Vlan100)# ip ospf area 0.0.0.0  
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf vrf Vrf-Blue
DELLSONiC(config-router-ospf)# network 10.10.150.0/24 area 0.0.0.0
DELLSONiC(config-router-ospf)# network 10.10.150.0/24 area 0


查看 OSPF 会话

 
DELLSONiC# show ip ospf neighbor

Neighbor ID  Pri      State        Dead Time         Address             Interface                     RXmtL RqstL DBsmL            
10.10.150.2   1      Full/DR       32.346s         10.10.150.2        Vlan100:10.10.150.1                0     0     0


配置 OSPF 路由器 ID


为 VRF 中的每个 OSPF 路由器明确配置 OSPFv2 路由器标识符。路由器 ID 配置是可选的。如果配置路由器 ID,则软件会选择该路由器 ID 作为 OSPF 路由器 ID。
每当未配置路由器 ID 时,将根据以下首选项进行路由器 ID 选择。
  • 最近使用的路由器 ID 值;(当用户取消配置路由器 ID 时,可能会发生这种情况)。
  • 路由器 ID 的 FRR 建议值。FRR 按以下顺序选择路由器 ID。
    1. FRR 全局模式配置的路由器 ID 值(如果有)。
    2. SONiC 物理和环回接口 IPv4 地址中最高的 IPv4 地址值。
使用此路由器模式命令配置或取消配置 OSPF 路由器 ID。路由器 ID 可以是任何 32 位未签名整数、十进制格式或点分 Ipv4 格式。OSPF 路由器 ID 在整个 OSPF 域中必须是唯一的。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# ospf router-id router-id

要删除:
 
DELLSONiC(config-router-ospf)# no ospf router-id router-id
 
  • router-id— 十进制或点分格式的 OSPF 路由器 ID

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# ospf router-id 1.1.1.1


配置 OSPF 区域级身份验证类型


您可以按区域配置 OSPFv2 身份验证类型。配置身份验证后,在该区域内配置的所有接口都使用已配置的身份验证类型。如果配置了任何接口模式身份验证类型,则该接口模式身份验证类型优先于区域级别配置。

用户未配置身份验证类型时,身份验证类型为无。用户可以启用纯文本身份验证类型或消息摘要类型的身份验证。每当为某个区域配置身份验证类型时,用户应在属于该区域的所有 OSPF 接口上配置相应的身份验证密钥(密码)。

使用此路由器模式命令可配置或取消配置某个区域的 OSPF 身份验证。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# area area-id authentication [message-digest]

要删除:
 
DELLSONiC(config-router-ospf)# no area area-id authentication [message-digest]
 
  • area-id - 十进制或虚线格式的 OSPF 区域 ID - A.B.C.D 或 0..4294967295
 
示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# area 0 authentication
or
DELLSONiC(config-router-ospf)# area 0 authentication message-digest


配置 OSPF 接口级身份验证类型和密钥


为各个 OSPF 接口配置 OSPFv2 身份验证类型和身份验证密钥或密码。如果用户未配置,身份验证类型为无。用户可以启用纯文本身份验证类型或消息摘要类型的身份验证。每当为接口配置身份验证类型时,用户都应为该 OSPF 接口配置相应的身份验证密钥(密码)。

纯文本身份验证的长度最多为 8 个字符。消息摘要 (MD5) 身份验证密钥最长可为 16 个字符。MD5 身份验证类型可以接受每个接口和接口 IP 最多 255 个身份验证密钥。每个 MD5 身份验证密钥都由值范围为 1 和 255 的身份验证密钥 id 唯一标识。身份验证密钥以加密形式保存。

使用此接口模式命令配置或取消配置 OSPF 消息身份验证。

要进行配置,请执行以下操作:
 
DELLSONiC(config-if-Eth1/47)# ip ospf authentication [null | message-digest] [if-ip-addr]
DELLSONiC(config-if-Eth1/47)# ip ospf authentication-key key [if-ip-addr]
DELLSONiC(config-if-Eth1/47)# ip ospf message-digest-key key-id md5 key [if-ip-addr]

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf authentication [null | message-digest] [if-ip-addr]
DELLSONiC(config-if-Eth1/47)# no ip ospf authentication-key [if-ip-addr]
DELLSONiC(config-if-Eth1/47)# no ip ospf message-digest-key key-id md5 [if-ip-addr]
 
  • key — 身份验证密钥密码(最多 8 或 16 个字符的字符串)
  • key-id- MD5 身份验证密钥标识符(1 到 255)
  • if-ip-addr - 接口 IP 地址 - A.B.C.D

  示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# interface Eth 1/47
DELLSONiC(config-if-Eth1/47)# ip ospf authentication
DELLSONiC(config-if-Eth1/47)# ip ospf authentication-key dellospfpswrd

DELLSONiC(config-if-Eth1/47)# ip ospf authentication 10.10.3.2
DELLSONiC(config-if-Eth1/47)# ip ospf authentication-key dellospfpswrd 10.10.3.2

DELLSONiC(config-if-Eth1/47)# ip ospf authentication message-digest
DELLSONiC(config-if-Eth1/47)# ip ospf message-digest-key 1 md5 dellospfpswrd
DELLSONiC(config-if-Eth1/47)# ip ospf message-digest-key 2 md5 dellospfpswrd

DELLSONiC(config-if-Eth1/47)# ip ospf authentication null


配置 OSPF 被动接口


使用路由器模式配置配置 OSPFv2 被动接口。在被动接口上,OSPF 不会触发 OSPF hello 或启动 OSPF 会话。被动接口在路由器 LSA 中通告为末节链路。要默认将所有 OSPF 接口配置为被动接口,请输入 passive-interface default 选项。要重新激活所有或指定的接口,请使用 no passive-interface 命令。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# passive-interface {default | Eth | Loopback | PortChannel | Vlan } [if-ip-addr]

要删除:
 
DELLSONiC(config-router-ospf)# no passive-interface {default | Eth | Loopback | PortChannel | Vlan } [if-ip-addr]
 
  • 以太币 |环回 |端口通道 |Vlan — 接口名称
  • if-ip-addr - 接口 IP 地址 - A.B.C.D

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# passive-interface default
DELLSONiC(config-router-ospf)# no passive-interface Eth 1/47


配置 OSPF 虚拟链路


OSPFv2 虚拟链路用于跨非主干区域连接主干路由器。用于配置虚拟链路的区域(称为中转区域)必须具有完整的路由信息。传输区域不能是存根区域。您必须在两端主干路由器上配置虚拟链路。

使用 OSPF 路由器模式配置配置虚拟链路,如下所示。单个虚拟链接命令提供选项,用于配置与虚拟链接相关的所有参数。虚拟链接可以配置明文密码、基于消息摘要的密码或根本不配置密码。配置明文和消息摘要密码时,必须配置相应的 authentication-key 或 message-digest-key 参数。身份验证密钥(密码)以加密形式保存在配置中。用户在配置身份验证密钥时应始终提供实际密码。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# area area-id virtual-link remote-id [ authentication [ null | message-digest ] | authentication-key key | message-digest-key key-id md5 key | dead-interval time-value | hello-interval time-value | retransmit-interval time-value | transmit-delay time-value ]

要删除:
 
DELLSONiC(config-router-ospf)# no area area-id virtual-link remote-id [ authentication [ null | message-digest ] | authentication-key key | message-digest-key key-id md5 key | dead-interval time-value | hello-interval time-value | retransmit-interval time-value | transmit-delay time-value ]
 
  • area-id - 十进制或虚线格式的 OSPF 区域 ID - A.B.C.D 或 0..4294967295
  • remote-id - 远程路由器 ID (虚线格式) - A.B.C.D
  • key — 身份验证密钥密码(最多 8 或 16 个字符的字符串)
  • key-id— MD5 身份验证密钥标识符(1 到 255)
  • time-value - 时间间隔值(以秒为单位)(1 到 65535)
示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# area 19 virtual-link 1.1.1.9

DELLSONiC(config-router-ospf)# area 19 virtual-link 1.1.1.9 authentication
DELLSONiC(config-router-ospf)# area 19 virtual-link 1.1.1.9 authentication-key dellospfpswrd

DELLSONiC(config-router-ospf)# area 19 virtual-link 1.1.1.9 authentication
message-digest
DELLSONiC(config-router-ospf)# area 19 virtual-link 1.1.1.9
message-digest-key 19 md5 dellospfpswrd

DELLSONiC(config-router-ospf)# area 19 virtual-link 1.1.1.9 authentication null

DELLSONiC(config-router-ospf)# area 19 virtual-link 1.1.1.9 dead-interval 60
DELLSONiC(config-router-ospf)# area 19 virtual-link 1.1.1.9 hello-interval 20
DELLSONiC(config-router-ospf)# area 19 virtual-link 1.1.1.9 retransmit-interval 15
DELLSONiC(config-router-ospf)# area 19 virtual-link 1.1.1.9 transmit-delay 10


配置 OSPF ABR 类型


OSPF 路由器 ABR 可以是 Cisco、IBM、shortcut 或 standard 类型。“Cisco”和“IBM”类型是等效的。ABR 行为的 OSPF 标准不允许 ABR 在与主干的链路中断时考虑通过非主干区域的路由,即使连接的非主干区域中还有其他 ABR 仍可到达主干,此限制主要是为了确保避免路由环路。

对于此版本中的默认值“Cisco”或“IBM”ABR 类型,此限制已取消,允许 ABR 考虑通过非主干区域从其他 ABR 学习的摘要,因此当且仅当主干链路关闭时,作为最后的手段通过非主干区域路由。

ospf abr-type 命令用于配置或取消配置 ABR 类型,如下所示。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# ospf abr-type [ cisco | ibm | shortcut | standard ]

要删除:
 
DELLSONiC(config-router-ospf)# no ospf abr-type [ cisco | ibm | shortcut | standard ]

示例:

 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# ospf abr-type standard


配置 OSPF 区域快捷方式


OSPF 主干区域负责非主干区域之间的路由分布。主干区域应该是连续的,但这并不总是意味着物理邻接。您可以使用虚拟连接实现骨干区域路由器连接。

通过配置快捷方式类型,您可以启用或禁用通往主干区域的快捷方式路由。当快捷方式类型为默认值时,仅当 ABR 没有指向主干区域的链接或此链接已丢失时,该区域才用于快捷方式。当快捷方式类型为“启用”时,则每次通过它的路线更便宜时,该区域都会用于快捷方式。当快捷方式类型为“disable”时,ABR 绝不会将该区域用于路线快捷方式。

在 OSPF 路由器配置模式下配置或取消配置 OSPFv2 区域快捷方式类型。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# area area-id shortcut {default | enable | disable}

要删除:
 
DELLSONiC(config-router-ospf)# no area area-id shortcut

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# area 1 shortcut enable


配置 OSPF RFC 兼容性


OSPFv2 RFC2328 是 RFC1583 的继任者,根据第 16.4 节中的第 G.2 节(更改),建议对路径偏好算法进行更改,以防止可能出现旧版本 OSPFv2 中可能出现的路由环路。更具体地说,它要求区域间路径和区域内骨干路径现在具有同等的优先权,但仍然比外部路径更受欢迎。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# compatible rfc1583

要删除:
 
DELLSONiC(config-router-ospf)# no compatible rfc1583

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# compatible rfc1583


配置 OSPF 邻接日志记录


通过配置邻接日志启用 OSPFv2 邻接状态日志。使用可选的 detail 参数,将显示邻接状态中的所有更改。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# log-adjacency-changes [detail]

要删除:
 
DELLSONiC(config-router-ospf)# no log-adjacency-changes

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# log-adjacency-changes detail
 

配置 OSPF LSA 计时器


配置 OSPFv2 LSA 刷新间隔、最小间隔和限制计时器:

要配置:
 
DELLSONiC(config-router-ospf)# refresh timer refresh-time
DELLSONiC(config-router-ospf)#  timers lsa min-arrival min-arr-time
DELLSONiC(config-router-ospf)#  timers throttle lsa all throttle-time

要删除:
 
DELLSONiC(config-router-ospf)# no refresh timer
DELLSONiC(config-router-ospf)# no timers lsa min-arrival
DELLSONiC(config-router-ospf)# no timers throttle lsa all
 
  • refresh-time — 刷新时间(10 到 1800 秒)
  • min-arr-time - 最短到达时间(0 到 600000 毫秒)
  • throttle-time — 限制时间(0 到 5000 毫秒)
示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)#  refresh timer 40
DELLSONiC(config-router-ospf)#  timers lsa min-arrival 30
DELLSONiC(config-router-ospf)#  timers throttle lsa all 150


配置 OSPF SPF 限制计时器


OSPFv2 SPF 算法节流计时器设置计算 SPF 时与触发计算的事件之间的初始延迟、初始保持时间和最大保持时间。时间以毫秒为单位指定,并且必须介于 0 到 600000 毫秒之间。

initial-delay 指定延迟 SPF 计算的最短时间。因此,它会影响在任何先前 SPF 计算的保留时间之外发生的事件之后 SPF 计算的延迟时间,并且还充当最短保留时间。

连续的 SPF 计算总是以至少“保持时间”毫秒为间隔。保持时间是自适应的,最初设置为使用 throttle 命令配置的初始保持时间。在上一个 SPF 计算的保留时间内发生的事件会导致保留时间增加初始保留时间,该时间由使用 throttle 命令配置的最大保留时间限制。如果自适应保持时间过去后没有发生任何 SPF 触发事件,则当前保持时间将重置为初始保持时间。您可以使用 show ip ospf 命令查看当前保持时间,其中它表示为
initial-hold-time 的乘数。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# timers throttle spf initial-delay initial-hold-time max-hold-time

要删除:
 
DELLSONiC(config-router-ospf)# no timers throttle spf
 
  • initial-delay — 时间值(0 到 600000 毫秒)
  • initial-hold-time — 时间值(0 到 600000 毫秒)
  • max-hold-time — 时间值(0 到 600000 毫秒)

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# timers throttle spf 200 400 10000

在上面的示例中,初始延迟设置为 200 毫秒,初始保持时间设置为 400 毫秒,最大保持时间为 10 秒。因此,事件(需要 SPF 计算)和 SPF 计算之间总是至少有 200 毫秒的间隔。进一步的连续 SPF 计算总是在 400 毫秒到 10 秒之间间隔,每当在前一次 SPF 计算的保持时间内发生 SPF 触发事件时,保持时间就会增加 400 毫秒。


配置 OSPF 最大指标通告


根据 RFC 313,OSPFv2 在其路由器 LSA 中将其传输链路描述为具有无限距离(最大公制),以便其他路由器避免计算通过路由器的传输路径,同时仍然能够通过路由器访问网络。
可以通过管理方式(即无限期)或有条件地启用此支持。最大指标路由器 LSA 的条件启用可以在启动后的几秒钟内进行。

在启动后的一段时间内启用此功能允许 OSPF 首先完全融合,而不会影响其他路由器使用的任何现有路由,同时仍允许访问任何连接的末节链路和/或重新分配的路由。

通过以管理方式启用此功能,无论出于何种原因,都可以无限期地进行管理干预。请注意,如果保存了配置,则也会保存 stub-router 命令的这种管理形式。如果稍后重新启动系统或 docker,则该命令会生效,直到手动取消配置。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# max-metric router-lsa administrative
DELLSONiC(config-router-ospf)#  max-metric router-lsa on-startup time-value

要删除:
 
DELLSONiC(config-router-ospf)# no max-metric router-lsa administrative
DELLSONiC(config-router-ospf)#  no max-metric router-lsa on-startup
 
  • time-value — 时间值(5 到 86400 秒)

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# max-metric router-lsa administrative
DELLSONiC(config-router-ospf)# max-metric router-lsa on-startup 60
 

配置 OSPF 路由距离


在路由器内分配具有用户配置的路由距离的 OSPFv2 计算路由。您可以在所有 OSPFv2 生成的路由上配置距离值。还可以根据 OSPF 路由的来源进行距离值配置,例如相对于当前路由器的区域内路由、区域间路由和外部路由。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# distance distance-value
DELLSONiC(config-router-ospf)# distance ospf intra-area distance-value
DELLSONiC(config-router-ospf)# distance ospf inter-area distance-value
DELLSONiC(config-router-ospf)# distance ospf external distance-value

要删除:
 
DELLSONiC(config-router-ospf)# no distance
DELLSONiC(config-router-ospf)# no distance ospf intra-area
DELLSONiC(config-router-ospf)# no distance ospf inter-area
DELLSONiC(config-router-ospf)# no distance ospf external
 
  • distance-value - 所有类型路线的距离值 (1...255)
示例:
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# distance 25
DELLSONiC(config-router-ospf)# distance ospf intra-area 30
DELLSONiC(config-router-ospf)# distance ospf inter-area 30
DELLSONiC(config-router-ospf)# distance ospf external 60


配置 OSPF 自动成本参考带宽


OSPFv2 根据 OSPF 接口成本计算路由成本。接口成本可以手动配置或自动计算。手动配置的接口成本优先于自动计算的接口成本。

接口成本自动计算是通过考虑参考带宽和接口/链路带宽来实现的。参考带宽成本被视为具有成本1。默认参考带宽为 100 GB。按照配置的链路带宽、链路实际速度或默认链路带宽 (10G) 的优先顺序选择链路带宽。链路费用的计算方式如下。

链路成本 =(参考带宽)/(链路带宽 + 0.5)

计算的链路成本可以小于 1,在这种情况下,始终四舍五入为链路成本 1。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# auto-cost reference-bandwidth ref-bandwidth

要删除:
 
DELLSONiC(config-router-ospf)# no auto-cost reference-bandwidth
 
  • ref-bandwidth - 参考带宽(1 到 4294967 MB)

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# auto-cost reference-bandwidth 10000


配置 OSPF 存根区域及其参数


将 OSPFv2 区域配置为具有或不具有摘要路由的存根区域。存根区域是没有路由器发起 OSPF 外部路由的区域。因此,在此区域中,所有外部路由都被视为可通过 ABR 访问。因此,此类区域的 ABR 不需要将 AS-外部 LSA 或 ASBR-摘要 LSA 传递到该区域。他们只需要将网络摘要 LSA 以及默认路由摘要一起传递到此类区域。没有摘要存根区域阻止 ABR 甚至将区域间摘要注入到指定的存根区域。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# area area-id stub [no-summary]
DELLSONiC(config-router-ospf)# area area-id default-cost cost-value

要删除:
 
DELLSONiC(config-router-ospf)# no area area-id stub [no-summary]
DELLSONiC(config-router-ospf)# no area area-id default-cost
 
  • area-id - 十进制或虚线格式的 OSPF 区域 ID - A.B.C.D 或 0..4294967295
  • 成本价值 — 默认成本(0 到 16777215)

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# area 1 stub
DELLSONiC(config-router-ospf)# area 2 stub no-summary
DELLSONiC(config-router-ospf)# area 2 default-cost 30
 

配置 OSPF 区域间摘要路由筛选器


使用前缀列表和范围列表管理 ABR 上的 OSPFv2 区域间摘要 LSA 路由传播。

使用 in 前缀列表将传入路由筛选出到 ABR 上的某个区域。同样,使用输出前缀列表筛选出某个区域的传出路由。

范围列表还可用于管理某个区域的前缀播发。使用范围列表,可以修改前缀以及成本或要通告的路由前缀。此选项将来自指定区域的区域内路径汇总到一个向其他区域公布的 Type-3 汇总 LSA。您只能在 ABR 中使用此配置,并且只能汇总路由器 LSA 和网络 LSA。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# area area-id filter-list prefix prefix-list in
DELLSONiC(config-router-ospf)# area area-id filter-list prefix prefix-list out
DELLSONiC(config-router-ospf)# area area-id range ip-prefix
DELLSONiC(config-router-ospf)# area area-id range ip-prefix not-advertise
DELLSONiC(config-router-ospf)# area area-id range ip-prefix cost cost-value
DELLSONiC(config-router-ospf)# area area-id range ip-prefix advertise cost cost-value
DELLSONiC(config-router-ospf)# area area-id range ip-prefix substitute sub-ip-prefix

要删除:
 
DELLSONiC(config-router-ospf)# no area area-id filter-list prefix in
DELLSONiC(config-router-ospf)# no area area-id filter-list prefix out
DELLSONiC(config-router-ospf)# no area area-id range ip-prefix
DELLSONiC(config-router-ospf)# no area area-id range ip-prefix not-advertise
DELLSONiC(config-router-ospf)# no area area-id range ip-prefix cost
DELLSONiC(config-router-ospf)# no area area-id range ip-prefix advertise cost
DELLSONiC(config-router-ospf)# no area area-id range ip-prefix substitute
 
  • area-id - 十进制或虚线格式的 OSPF 区域 ID - A.B.C.D 或 0..4294967295
  • prefix-list — IPv4 前缀列表名称
  • ip-prefix - 摘要路由地址范围前缀 - A.B.C.D/mask 
  • cost-value - 成本值 - <0..16777215> 
  • sub-ip-prefix - 地址前缀 - A.B.C.D/mask 

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# area 0 filter-list prefix arealistin in
DELLSONiC(config-router-ospf)# area 0 filter-list prefix arealistout out
 

配置 OSPF 路由重新分发


OSPFv2 可以将外部路由重新分配到 OSPF 路由域中。将BGP路由、静态路由、连接路由和内核路由重新分配到OSPF路由域。除了明确指定的成本和指标类型外,还使用路由映射管理路由重新分配。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# redistribute {kernel | connected | static| bgp} [metric metric-value| metric-type metric-type-value | route-map rmap-name}
DELLSONiC(config-router-ospf)# default-metric metric-value

要删除:
 
DELLSONiC(config-router-ospf)# no redistribute {kernel | connected | static | bgp} [metric | metric-type | route-map}
DELLSONiC(config-router-ospf)# no default-metric
 
  • metric-value — 应用于路由的路由成本(0 到 16777214)
  • metric-type-value — 指标类型(1 和 2)
  • rmap-name - 要应用于路由的路由映射的名称

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# redistribute bgp
DELLSONiC(config-router-ospf)# redistribute static metric 20 metric-type 1
DELLSONiC(config-router-ospf)# redistribute bgp route-map ospf-rmap
DELLSONiC(config-router-ospf)# redistribute bgp metric 20 metric-type 1 route-map ospfrmap
DELLSONiC(config-router-ospf)# default-metric 30
 

配置 OSPF 默认路由发起


默认路由可以源自 OSPF 路由域。此选项将生成一个 AS-外部 LSA,用于描述具有指定指标和指标类型的所有支持外部路由的区域的默认路由。如果指定了“always”选项,则始终通告默认路由,即使路由表中不存在默认路由也是如此。

要进行配置,请执行以下操作:
 
DELLSONiC(config-router-ospf)# default-information originate [{ always | metric metric-value| metric-type metric-type-value | route-map rmap-name }]

要删除:
 
DELLSONiC(config-router-ospf)# no default-information originate [{ always | metric | metric-type | route-map }]
 
  • metric-value — 应用于路由的路由成本(0 到 16777214)
  • metric-type-value — 指标类型(1 和 2)
  • rmap-name - 要应用于路由的路由映射的名称

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# router ospf
DELLSONiC(config-router-ospf)# default-information originate
DELLSONiC(config-router-ospf)# default-information originate always
DELLSONiC(config-router-ospf)# default-information originate route-map ospf-rmap
DELLSONiC(config-router-ospf)# default-information originate metric 20 metric-type 1 route-map ospfrmap
 

配置 OSPF 接口参数


在 SONiC 接口配置模式下配置 OSPF 接口参数。接口配置包括:
  • 与接口的区域关联
  • 接口类型、MTU
  • 消息身份验证参数
  • 会话计时器间隔参数
  • BFD(BFD)

通过指定接口 IPv4 地址,还可以将接口参数与接口的特定接口地址相关联。指定接口地址时,此类配置参数仅适用于与相应接口地址关联的 OSPF 会话。

要进行配置,请执行以下操作:
 
DELLSONiC(config-if-Eth1/47)# ip ospf area area-id [if-ip-addr]

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf area area-id [if-ip-addr]
 
  • area-id - 十进制或虚线格式的 OSPF 区域 ID - A.B.C.D 或 0..4294967295
  • if-ip-addr - 接口 IP 地址

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# int Eth 1/47
DELLSONiC(config-if-Eth1/47)# ip ospf area 10
DELLSONiC(config-if-Eth1/47)# ip ospf area 0.0.0.0 10.3.1.2

在 OSPF 接口配置模式下配置 OSPFv2 接口网络类型。默认情况下,OSPF 接口网络是广播网络类型。

要进行配置,请执行以下操作:
 
DELLSONiC(config-if-Eth1/47)# ip ospf network {broadcast | point-to-point}

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf network {broadcast | point-to-point}

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# int Eth 1/47
DELLSONiC(config-if-Eth1/47)# ip ospf network broadcast

DELLSONiC(config)# int Eth 1/8
DELLSONiC(config-if-Eth1/8)# ip ospf network point-to-point

在OSPF接口配置模式下配置OSPFv2接口会话优先级参数。优先级最高的路由器更有资格成为指定路由器。将该值设置为 0 会使路由器没有资格成为指定路由器。默认值为 1。

要进行配置,请执行以下操作:
 
DELLSONiC(config-if-Eth1/47)# ip ospf priority priority-value [if-ip-addr]

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf priority [if-ip-addr]
 
  • priority-value — 会话优先级(0 到 255)
  • if-ip-addr - 接口 IP 地址

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# int Eth 1/47
DELLSONiC(config-if-Eth1/47)# ip ospf priority 10

在 OSPF 接口配置模式下配置 OSPFv2 接口会话身份验证参数:

要配置:
 
DELLSONiC(config-if-Eth1/47)# ip ospf authentication [null | message-digest] [if-ip-addr]
DELLSONiC(config-if-Eth1/47)# ip ospf authentication-key key [if-ip-addr]
DELLSONiC(config-if-Eth1/47)# ip ospf message-digest-key key-id md5 key [if-ip-addr]

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf authentication [null | message-digest] [if-ip-addr]
DELLSONiC(config-if-Eth1/47)# no ip ospf authentication-key [if-ip-addr]
DELLSONiC(config-if-Eth1/47)# no ip ospf message-digest-key key-id md5 [if-ip-addr]
 
  • if-ip-addr - 接口 IPv4 地址
  • key - 身份验证密钥密码(最多 8 或 16 个字符)
  • key-id- MD5 身份验证密钥标识符(1 到 255)
  • if-ip-addr - 接口 IP 地址

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# interface Eth1/1
DELLSONiC(config-if-Eth1/1)# ip ospf authentication
DELLSONiC(config-if-Eth1/1)# ip ospf authentication-key ospfpswd

DELLSONiC(config)# interface Eth1/2
DELLSONiC(config-if-Eth1/2)# ip ospf authentication 10.10.3.2
DELLSONiC(config-if-Eth1/2)# ip ospf authentication-key ospfpswd 10.10.3.2

DELLSONiC(config)# interface Eth1/3
DELLSONiC(config-if-Eth1/3)# ip ospf authentication message-digest
DELLSONiC(config-if-Eth1/3)# ip ospf message-digest-key 1 md5 ospfpswd1
DELLSONiC(config-if-Eth1/3)# ip ospf message-digest-key 2 md5 ospfpswd2
DELLSONiC(config-if-Eth1/3)# ip ospf message-digest-key 9 md5 ospfpswd9

DELLSONiC(config)# interface Eth1/4
DELLSONiC(config-if-Eth1/4)# ip ospf authentication null

在 OSPF 接口配置模式下配置 OSPFv2 接口会话 BFD。默认情况下,OSPF 接口 BFD 处于禁用状态。

要进行配置,请执行以下操作:
 
DELLSONiC(config-if-Eth1/47)# ip ospf bfd

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf bfd

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# interface Eth1/1
DELLSONiC(config-if-Eth1/1)# ip ospf bfd

在 OSPF 接口配置模式下配置 OSPFv2 接口成本。成本值设置为 router-LSA 的指标字段,用于 SPF 计算。

要进行配置,请执行以下操作:
 
DELLSONiC(config-if-Eth1/47)# ip ospf cost cost-value [if-ip-addr]

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf cost [if-ip-addr]
 
  • if-ip-addr - 接口 IP 地址
  • cost-value — 接口成本(1 至 65535)

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# interface Eth1/1
DELLSONiC(config-if-Eth1/1)# ip ospf cost 50

在 OSPF 接口配置模式下配置 OSPFv2 接口会话 MTU 忽略。默认情况下不会忽略 MTU。如果未配置 MTU 忽略,则 OSPF 会话接口端的 MTU 值应匹配。当存在大量 OSPF 路由前缀且路由器 LSA 消息无法在 MTU 大小内容纳它们时,配置 MTU 忽略并不能保证会话建立。

要进行配置,请执行以下操作:
 
DELLSONiC(config-if-Eth1/47)# ip ospf mtu-ignore [if-ip-addr]

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf mtu-ignore [if-ip-addr]
 
  • if-ip-addr - 接口 IP 地址

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# interface Eth1/1
DELLSONiC(config-if-Eth1/1)# ip ospf mtu-ignore

在 OSPF 接口配置模式下配置 OSPFv2 接口会话 hello 计时器。配置后,在指定接口上每隔几秒发送一次 Hello 数据包。对于连接到通用网络的所有路由器,此值必须相同。默认值为 10 秒。

要进行配置,请执行以下操作:
 
DELLSONiC(config-if-Eth1/47)# ip ospf hello-interval time-interval [if-ip-addr]

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf hello-interval [if-ip-addr]
 
  • if-ip-addr - 接口 IP 地址
  • time-interval — 计时器值(1 到 65535 秒)

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# interface Eth1/1
DELLSONiC(config-if-Eth1/1)# ip ospf hello-interval 15

在 OSPF 接口配置模式下配置 OSPFv2 接口会话传输延迟计时器。配置后,LSA 的期限应在传输时按此值递增。默认值为 1 秒。

要进行配置,请执行以下操作:
 
DELLSONiC(config-if-Eth1/47)# ip ospf transmit-delay time-interval [if-ip-addr]

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf transmit-delay [if-ip-addr]
 
  • if-ip-addr - 接口 IP 地址
  • time-interval — 计时器值(1 到 65535 秒)

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# interface Eth1/1
DELLSONiC(config-if-Eth1/1)# ip ospf transmit-delay 20

在 OSPF 接口配置模式下配置 OSPFv2 接口会话重传间隔计时器。在重新传输数据库描述和链路状态请求数据包时使用此值。默认值为 5 秒。

要进行配置,请执行以下操作:
 
DELLSONiC(config-if-Eth1/47)# ip ospf retransmit-interval time-interval [if-ip-addr]

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf retransmit-interval [if-ip-addr]
 
  • if-ip-addr - 接口 IP 地址
  • time-interval — 计时器值(2 到 65535 秒)

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# interface Eth1/1
DELLSONiC(config-if-Eth1/1)# ip ospf retransmit-interval 25

在 OSPF 接口配置模式下配置 OSPFv2 接口死区。OSPF 路由器死区间隔计时器值用于会话等待或非活动计时器。对于连接到通用网络的所有路由器,此值必须相同。默认值为 40 秒。如果指定了“minimal”而不是显式等待时间,则死间隔设置为 1 秒,并且必须指定一个 hello-multiplier。hello-multiplier 指定每秒要发送多少个 Hello。乘数值可以是 1(每 500 毫秒)到 10(每 50 毫秒)。因此,OSPF 可以有 1 秒的收敛时间。如果指定此形式,则 Hello 数据包中通告的 hello-interval 设置为 0,并且不会选中收到的 Hello 数据包上的 hello-interval,因此 hello-multiplier 在通用链路上的多个路由器之间不需要相同。

要进行配置,请执行以下操作:
 
DELLSONiC(config-if-Eth1/47)# ip ospf dead-interval time-interval [if-ip-addr]
DELLSONiC(config-if-Eth1/47)# ip ospf dead-interval minimal hello-multiplier multiplier [if-ip-addr]

要删除:
 
DELLSONiC(config-if-Eth1/47)# no ip ospf dead-interval [if-ip-addr]
DELLSONiC(config-if-Eth1/47)# no ip ospf dead-interval minimal hello-multiplier [if-ip-addr]
 
  • if-ip-addr - 接口 IP 地址
  • time-interval — 计时器值(1 到 65535 秒)
  • multiplier - 无效间隔 hello 乘数值(1 到 10 秒)

示例:
 
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure terminal
DELLSONiC(config)# interface Eth1/1
DELLSONiC(config-if-Eth1/1)# ip ospf dead-interval 60
DELLSONiC(config-if-Eth1/1)# ip ospf dead-interval minimal hello-multiplier 4
 

OSPF operational data display 命令


SONiC 提供 display 命令来显示 OSPF 路由器、OSPF 会话和 OSPF 接口的运行状态。
 

查看 OSPF 路由器信息

 
show ip ospf [vrf vrf-name]
 
  • vrf-name - VRF 名称

示例:

 
DELLSONiC# show ip ospf
OSPF Routing Process, Router ID: 1.1.1.1
 Supports only single TOS (TOS0) routes
 This implementation conforms to RFC2328
 RFC1583Compatibility flag is enabled
 OpaqueCapability flag is disabled
 Initial SPF scheduling delay 0 millisec(s)
 Minimum hold time between consecutive SPFs 50 millisec(s)
 Maximum hold time between consecutive SPFs 5000 millisec(s)
 Hold time multiplier is currently 1
 time is 92031756
 SPF algorithm last executed 1065d4h22m ago
 Last SPF duration 0.0s
 SPF timer is inactive
 LSA minimum interval 5000 msecs
 LSA minimum arrival 1000 msecs
 Write Multiplier set to 20
 Refresh timer 10 secs
 Number of external LSA 0. Checksum Sum 0x0
 Number of opaque AS LSA 0. Checksum Sum 0x0
 Number of areas attached to this router: 2
 Area ID: 0.0.0.0 (Backbone)
 Number of interfaces in this area: Total: 1 , Active: 1
 Number of fully adjacent neighbors in this area: 1
 Area has no authentication
 SPF algorithm executed 8 times
 Number of LSA 3
 Number of router LSA 2. Checksum Sum 0x40f64b4000000000
 Number of network LSA 1. Checksum Sum 0x40d5adc000000000
 Number of summary LSA 0. Checksum Sum 0x0
 Number of ASBR summary LSA 0. Checksum Sum 0x0
 Number of NSSA LSA 0. Checksum Sum 0x0
 Number of opaque link LSA . Checksum Sum 0x
 Number of opaque area LSA 0. Checksum Sum 0x0
 Area ID: 0.0.0.1
 Number of interfaces in this area: Total: 1 , Active: 1
 Number of fully adjacent neighbors in this area: 0
 Area has no authentication
 SPF algorithm executed 1 times
 Number of LSA 2
 Number of router LSA 0. Checksum Sum 0x0
 Number of network LSA 0. Checksum Sum 0x0
 Number of summary LSA 2. Checksum Sum 0x40f1f61000000000
 Number of ASBR summary LSA 0. Checksum Sum 0x0
 Number of NSSA LSA 0. Checksum Sum 0x0
 Number of opaque link LSA . Checksum Sum 0x
 Number of opaque area LSA 0. Checksum Sum 0x0


查看 OSPF 邻居信息

 
show ip ospf [vrf vrf-name ] neighbor [detail | if-name | nbr-ip ]
 
  • vrf-name - VRF 名称
  • if-name— OSPF 接口名称
  • nbr-ip - 邻居路由器 ID

示例:
 
DELLSONiC# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface RXmtL
RqstL DBsmL
10.59.142.247 1 Full/Backup 37.343s 64.1.1.2 Eth 1/2:64.1.1.1 0
 0 0
DELLSONiC# show ip ospf neighbor Eth1/3 | no-more
Neighbor ID Pri State Dead Time Address Interface RXmtL
RqstL DBsmL
2.2.2.2 1 Full/Backup 38.245s 64.1.1.2 Eth 1/4:64.1.1.1 0
 0 0
DELLSONiC# show ip ospf neighbor detail
Neighbor 10.59.142.247, interface address 64.1.1.2
 In the area 0.0.0.0 via interface Eth 1/2
 Neighbor priority is 1, State is Full, 6 state changes
 Most recent state change statistics:
 Progressive change 7h3m25s ago
 DR is 64.1.1.1, BDR is 64.1.1.2
 Options 2 *|-|-|-|-|-|E|-
 Dead timer due in 30.687s
 Database Summary List 0
 Link State Request List 0
 Link State Retransmission List 0
 Thread Inactivity Timer on
 Thread Database Description Retransmission off
 Thread Link State Request Retransmission on
 Thread Link State Update Retransmission on


Leaf1# show ip ospf neighbor 2.2.2.2
 Neighbor 2.2.2.2, interface address 64.1.1.2
 In the area 0.0.0.0 via interface Eth 1/2
 Neighbor priority is 1, State is Full, 5 state changes
 Most recent state change statistics:
 Progressive change 0h1m11s ago
 DR is 64.1.1.1, BDR is 64.1.1.2
 Options 2 *|-|-|-|-|-|E|-
 Dead timer due in 33.203s
 Database Summary List 0
 Link State Request List 0
 Link State Retransmission List 0
 Thread Inactivity Timer on
 Thread Database Description Retransmision off
 Thread Link State Request Retransmission on
 Thread Link State Update Retransmission on


查看 OSPF 接口信息

 
show ip ospf interface [if-name | traffic ]
 
  • if-name— OSPF 接口名称

示例:
 
DELLSONiC# show ip ospf interface
VRF Name: default
Eth 1/2 is up
 ifindex 128, MTU 9100 bytes, BW 25000 Mbit UP,BROADCAST,RUNNING,MULTICAST
 Internet Address 64.1.1.1/24, Broadcast 64.1.1.255, Area 0.0.0.0
 MTU mismatch detection: enabled
 Router ID 10.59.143.131, Network Type BROADCAST, Cost: 4
 Transmit Delay is 1 sec, State DR, Priority 1
 Backup Designated Router (ID) 10.59.142.247, Interface Address 64.1.1.2
 Saved Network-LSA sequence number 0x8000000f
 Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
 Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
 Hello due in 9.023s
 Neighbor Count is 1, Adjacent neighbor count is 1


DELLSONiC# show ip ospf interface Eth 1/3
VRF Name: default
Eth 1/4 is up
 ifindex 926, MTU 9100 bytes, BW 25000 Mbit UP,BROADCAST,RUNNING,MULTICAST
 Internet Address 65.1.1.1/24, Broadcast 65.1.1.255, Area 0.0.0.1
 MTU mismatch detection: enabled
 Router ID 1.1.1.1, Network Type BROADCAST, Cost: 4
 Transmit Delay is 1 sec, State DR, Priority 1
 Backup Designated Router (ID) 2.2.2.2, Interface Address 65.1.1.2
 Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
 Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
 Hello due in 7.957s
 Neighbor Count is 1, Adjacent neighbor count is 1


DELLSONiC# show ip ospf interface traffic
Interface HELLO DB-Desc LS-Req LS-Update LS-Ack
 Rx/Tx Rx/Tx Rx/Tx Rx/Tx Rx/Tx
-----------------------------------------------------------------------------------------
---
Eth 1/2 2563/2563 3/3 1/1 17/30 29/16
Leaf1# show ip ospf interface traffic Eth1/3
Interface HELLO DB-Desc LS-Req LS-Update LS-Ack
 Rx/Tx Rx/Tx Rx/Tx Rx/Tx Rx/Tx
-----------------------------------------------------------------------------------------

Eth1/3 19/22 2/3 1/1 3/3 2/2
 

查看 OSPF 数据库信息

 
show ip ospf [vrf vrf-name ] database [asbr-summary | external | network | router | summary | opaque-link]
 
  • vrf-name — VRF 名称

示例:
 
DELLSONiC# show ip ospf database
VRF Name: default
 OSPF Router with ID (5.5.5.5)
 Router Link States (Area 0.0.0.0)
Link ID ADV Router Age Seq# CkSum Link count
3.3.3.3 3.3.3.3 988 0x80000003 0x04ec 1
5.5.5.5 5.5.5.5 988 0x80000008 0x6f6b 1
 Net Link States (Area 0.0.0.0)
Link ID ADV Router Age Seq# CkSum
10.10.10.2 5.5.5.5 988 0x80000002 0xcc38
 Link-Local Opaque-LSA (Area 0.0.0.0)
Opaque-Type/Id ADV Router Age Seq# CkSum
3.0.0.0 3.3.3.3 89 0x80000001 0x4a24
DELLSONiC# show ip ospf database network
VRF Name: default
 OSPF Router with ID (10.59.143.131)
 Net Link States (Area 0.0.0.0)
 LS age: 1602
 Options: 0x2 : *|-|-|-|-|-|E|-
 LS Flags: 0x3
 LS Type: network-LSA
 Link State ID: 64.1.1.1 (address of Designated Router)
 Advertising Router: 10.59.143.131
 LS Seq Number: 8000000f
 Checksum: 0x1c70
 Length: 32
 Network Mask: /24
 Attached Router: 10.59.142.247
 Attached Router: 10.59.143.131

DELLSONiC# show ip ospf database summary
VRF Name: default
 OSPF Router with ID (1.1.1.1)
 Summary Link States (Area 0.0.0.0)
 LS age: 468
 Options: 0x2 : *|-|-|-|-|-|E|-
 LS Flags: 0x11
 LS Type: summary-LSA
 Link State ID: 65.1.1.0 (summary Network Number)
 Advertising Router: 1.1.1.1
 LS Seq Number: 80000001
 Checksum: 0x0e04
 Length: 28
 Network Mask: /24
 TOS: 0 Metric: 4
 LS age: 429
 Options: 0x2 : *|-|-|-|-|-|E|-
 LS Flags: 0x6
 LS Type: summary-LSA
 Link State ID: 65.1.1.0 (summary Network Number)
 Advertising Router: 2.2.2.2
 LS Seq Number: 80000002
 Checksum: 0xed1f
 Length: 28
 Network Mask: /24
 TOS: 0 Metric: 4
 Summary Link States (Area 0.0.0.1)
 LS age: 468
 Options: 0x2 : *|-|-|-|-|-|E|-
 LS Flags: 0x11
 LS Type: summary-LSA
 Link State ID: 64.1.1.0 (summary Network Number)
 Advertising Router: 1.1.1.1
 LS Seq Number: 80000001
 Checksum: 0x1bf7
 Length: 28
 Network Mask: /24
 TOS: 0 Metric: 4
 LS age: 429
 Options: 0x2 : *|-|-|-|-|-|E|-
 LS Flags: 0x6
 LS Type: summary-LSA
 Link State ID: 64.1.1.0 (summary Network Number)
 Advertising Router: 2.2.2.2
 LS Seq Number: 80000002
 Checksum: 0xfa13
 Length: 28
 Network Mask: /24
 TOS: 0 Metric: 4

DELLSONiC# show ip ospf database asbr-summary
VRF Name: default
 OSPF Router with ID (1.1.1.1)
 ASBR-Summary Link States (Area 0.0.0.0)
 LS age: 38
 Options: 0x2 : *|-|-|-|-|-|E|-
 LS Type: summary-LSA
 Link State ID: 2.2.2.2 (AS Boundary Router address)
 Advertising Router: 1.1.1.1
 LS Seq Number: 80000001
 Checksum: 0x0b41
 Length: 28
 Network Mask: /0
 TOS: 0 Metric: 4

DELLSONiC# show ip ospf database external
VRF Name: default
 OSPF Router with ID (1.1.1.1)
 AS External Link States
LS age: 52
 Options: 0x2 : *|-|-|-|-|-|E|-
 LS Flags: 0x6
 LS Type: AS-external-LSA
 Link State ID: 25.1.1.1 (External Network Number)
 Advertising Router: 2.2.2.2
 LS Seq Number: 80000001
 Checksum: 0x0892
 Length: 36
 Network Mask: /32
 Metric Type: 2 (Larger than any link state path)
 TOS: 0
 Metric: 20
 Forward Address: 0.0.0.0
 External Route Tag: 0

DELLSONiC# show ip ospf database self-originate
VRF Name: default
 OSPF Router with ID (1.1.1.1)
 Router Link States (Area 0.0.0.0)
Link ID ADV Router Age Seq# CkSum Link count
1.1.1.1 1.1.1.1 777 0x80000004 0x7b42 1
 Net Link States (Area 0.0.0.0)
Link ID ADV Router Age Seq# CkSum
64.1.1.1 1.1.1.1 777 0x80000001 0x8581
 Summary Link States (Area 0.0.0.0)
Link ID ADV Router Age Seq# CkSum Route
65.1.1.0 1.1.1.1 816 0x80000001 0x0e04 65.1.1.0/24
 ASBR-Summary Link States (Area 0.0.0.0)
Link ID ADV Router Age Seq# CkSum
2.2.2.2 1.1.1.1 360 0x80000001 0x0b41
 Router Link States (Area 0.0.0.1)
Link ID ADV Router Age Seq# CkSum Link count
1.1.1.1 1.1.1.1 776 0x80000004 0x8d2e 1
 Net Link States (Area 0.0.0.1)
Link ID ADV Router Age Seq# CkSum
65.1.1.1 1.1.1.1 776 0x80000001 0x788d
 Summary Link States (Area 0.0.0.1)
Link ID ADV Router Age Seq# CkSum Route
64.1.1.0 1.1.1.1 816 0x80000001 0x1bf7 64.1.1.0/24

DELLSONiC# show ip ospf database network adv-router 1.1.1.1
VRF Name: default
 OSPF Router with ID (1.1.1.1)
 Net Link States (Area 0.0.0.0)
 LS age: 886
 Options: 0x2 : *|-|-|-|-|-|E|-
 LS Flags: 0x3
 LS Type: network-LSA
 Link State ID: 64.1.1.1 (address of Designated Router)
 Advertising Router: 1.1.1.1
 LS Seq Number: 80000001
Checksum: 0x8581
 Length: 32
 Network Mask: /24
 Attached Router: 1.1.1.1
 Attached Router: 2.2.2.2
 Net Link States (Area 0.0.0.1)
 LS age: 886
 Options: 0x2 : *|-|-|-|-|-|E|-
 LS Flags: 0x3
 LS Type: network-LSA
 Link State ID: 65.1.1.1 (address of Designated Router)
 Advertising Router: 1.1.1.1
 LS Seq Number: 80000001
 Checksum: 0x788d
 Length: 32
 Network Mask: /24
 Attached Router: 1.1.1.1
 Attached Router: 2.2.2.2
DELLSONiC# show ip ospf database opaque-link
VRF Name: default
 OSPF Router with ID (5.5.5.5)
 Link-Local Opaque-LSA (Area 0.0.0.0)
 LS age: 94
 Options: 0x66 : *|O|-|-|-|-|E|-
 LS Flags: 0x6
 LS Type: Link-Local Opaque-LSA
 Link State ID: 3.0.0.0 (Link-Local Opaque-Type/ID)
 Advertising Router: 3.3.3.3
 LS Seq Number: 80000001
 Checksum: 0x4a24
 Length: 44


查看 OSPF 路由信息

 
show ip ospf [ vrf vrf-name ] route
 
  • vrf-name - VRF 名称

示例:

 
DELLSONiC# show ip ospf vrf Vrf1 route | no-more
VRF Name: Vrf1
============ OSPF network routing table ============
N 101.1.1.0/24 [10] area: 0.0.0.0
 directly attached to Vlan101
============ OSPF router routing table =============
============ OSPF external routing table ===========
 

OSPFv2 正常重启


当参与 OSPF 的路由器重新启动时,会出现一段时间的流量丢失,直到路由器重新联机并重新学习路由。

RFC 3623 指定了 OSPF 的平稳重启增强功能,如下所示:
  • 尝试正常重启的路由器发起链路本地不透明 LSA (Grace-LSA),宣布其打算在指定的时间量或宽限期内执行正常重启。
  • 在宽限期内,邻居会继续在其 LSA 中宣布重新启动路由器,就好像它完全相邻(即,OSPF 邻居状态为 Full),但前提是网络拓扑保持静态(即,具有 LS 类型 1 到 5 和 7 的链路状态数据库中的 LSA 的内容保持不变, 并允许定期刷新)。

正常重启允许重启路由器通知其邻居它将重启。当邻居收到该情况的通知时,它们会继续将流量转发到重新启动的节点。由于重新启动节点的转发表在正常重新启动期间保留,因此可以避免流量丢失。


计划内中断


Enterprise SONiC 仅在计划内中断时支持 OSPF 平稳重启。

为 OSPF 实例启用了正常重启。系统热重启是使用 warm-reboot 命令触发的。


重新启动和帮助程序节点


通过正常重启,有两种类型的设备参与 OSPF 网络。它们是重新启动和帮助节点。

重新启动节点是正常重新启动而不会丢失流量的设备。当重新启动的节点执行正常重新启动时,它会在所有 OSPF 接口上泛洪链路本地不透明 LSA (grace-LSA)。这些宽限 LSA 通知帮助程序路由器邻居打算重新启动。

帮助程序节点可帮助重新启动节点,以避免流量丢失。辅助节点监视网络的拓扑变化。如果网络中没有变化,帮助程序将继续通告其 LSA,就像重新启动的节点保持连续 OSPF 操作一样。帮助程序 LSA 继续通过网段列出与重启节点的邻接关系,而不考虑重启节点的同步状态。


配置 OSPFv2 正常重启


要配置正常重启,请按照下列步骤操作:

1.启用正常重新启动。
 
DELLSONiC(config-router-ospf)# graceful-restart [grace-period grace-period]
 
  • grace-period — 在该宽限期之前,邻居或帮助程序认为重新启动节点已失效。范围为 1 到 1800 秒。默认宽限期为 120 秒

2.配置 OSPFv2 不透明功能,以帮助重新启动路由器启动宽限 LSA。
 
DELLSONiC (config-router-ospf)# capability opaque

3.在系统上为所有或特定路由器 ID 配置 OSPFv2 平稳重启帮助程序。在用于帮助重新启动路由器的所有节点上执行此操作。
 
DELLSONiC (config-router-ospf)# graceful-restart helper enable [router-id]
 
  • router-id — 使用路由器 ID 为特定邻居配置正常重启帮助程序支持。

4.(可选)在帮助程序节点上配置宽限时间。此配置确定帮助程序支持正常重启的时间段。
 
DELLSONiC (config-router-ospf)# graceful-restart helper supported-grace-time grace-time
 
  • grace-time— 配置宽限时间。范围为 10 到 1800 秒。默认值为 120 秒。

5.(可选)在帮助程序节点上配置严格的 LSA 检查。如果配置了此命令,则帮助程序会在发生 LSA 更改时取消正常重启,这会影响重启路由器。默认情况下,严格 LSA 检查处于启用状态。
 
DELLSONiC (config-router-ospf)# graceful-restart helper strict-lsa-checking

6.(可选)仅为计划内重启配置帮助程序支持。
 
DELLSONiC (config-router-ospf)# graceful-restart helper planned-only
 

查看 OSPFv2 正常重启信息


使用以下命令查看正常重新启动帮助程序信息。

查看常规 OSPF 信息,包括是否启用了正常重启和不透明功能。
 
sonic# show ip ospf
VRF Name: default
OSPF Routing Process, Router ID: 1.1.1.2
Supports only single TOS (TOS0) routes
This implementation conforms to RFC2328
RFC1583Compatibility flag is disabled
OpaqueCapability flag is enabled
Graceful-Restart is enabled
Stub router advertisement is configured
 Enabled for 600s after start-up
Initial SPF scheduling delay 0 millisec(s)
Minimum hold time between consecutive SPFs 50 millisec(s)
Maximum hold time between consecutive SPFs 5000 millisec(s)
Hold time multiplier is currently 1
SPF algorithm last executed 19h39m37s ago
Last SPF duration 72320 usecs
SPF timer is inactive
LSA minimum interval 5000 msecs
LSA minimum arrival 0 msecs
Write Multiplier set to 20
Refresh timer 10 secs
Maximum multiple paths(ECMP) supported 256
Number of external LSA 0. Checksum Sum 0x00000000
Number of opaque AS LSA 0. Checksum Sum 0x00000000
Number of areas attached to this router: 1
Area ID: 0.0.0.0 (Backbone)
 Number of interfaces in this area: Total: 224 , Active: 224
 Number of fully adjacent neighbors in this area: 32
 Area has simple password authentication
 SPF algorithm executed 247 times
 Number of LSA 6068
 Number of router LSA 6. Checksum Sum 0x00020692
 Number of network LSA 62. Checksum Sum 0x001ab353
 Number of summary LSA 6000. Checksum Sum 0x0bc36229
 Number of ASBR summary LSA 0. Checksum Sum 0x00000000
 Number of NSSA LSA 0. Checksum Sum 0x00000000
 Number of opaque link LSA 0. Checksum Sum 0x00000000
 Number of opaque area LSA 0. Checksum Sum 0x00000000

查看 OSPF 邻居信息以及有关正常重启帮助程序的详细信息。
 
sonic# show ip ospf neighbor detail
Neighbor 13.13.13.13, interface address 192.168.10.1
 In the area 0.0.0.0 via interface Ethernet64
 Neighbor priority is 1, State is Full, 6 state changes
 Most recent state change statistics:
 Progressive change 17h32m19s ago
 DR is 192.168.10.1, BDR is 192.168.10.2
 Options 66 *|O|-|-|-|-|E|-
 Dead timer due in 0.717s
 Database Summary List 0
 Link State Request List 0
  Link State Retransmission List 0
 Thread Inactivity Timer on
 Thread Database Description Retransmision off
 Thread Link State Request Retransmission on
 Thread Link State Update Retransmission on
 Graceful restart Helper info:
 Graceful Restart HELPER Status: Inprogress
 Graceful Restart grace period time: 250 (seconds).
 Graceful Restart reason: Software restart

查看 OSPF 正常重启帮助程序信息。
 
sonic# show ip ospf graceful-restart helper
 VRF Name: default
 OSPF Router with ID (14.14.14.14)
 Graceful restart helper support enabled.
 Strict LSA check is enabled.
 Helper supported for planned restarts only.
 Supported Graceful restart interval: 1600(in seconds).
 Enable Router List:
 ['13.13.13.13']

查看 OSPF 详细正常重启帮助程序信息。
 
sonic# show ip ospf graceful-restart helper detail
 VRF Name: default
 OSPF Router with ID (14.14.14.14)
 Graceful restart helper support enabled.
 Strict LSA check is enabled.
 Helper supported for planned restarts only.
 Supported Graceful restart interval: 1600(in seconds).
 Enable Router List:
 ['13.13.13.13']
 Number of Active neighbours in graceful restart: 4
 Neighbour 1:
 Address: 192.168.10.1
 Routerid: 13.13.13.13
 Received Grace period: 250(in seconds).
 Actual Grace period: 250(in seconds).
 Remaining GraceTime: 245(in seconds).
 Graceful Restart reason: Software restart.
 Neighbour 2:
 Address: 192.168.20.1
 Routerid: 13.13.13.13
 Received Grace period: 250(in seconds).
 Actual Grace period: 250(in seconds).
 Remaining GraceTime: 245(in seconds).
 Graceful Restart reason: Software restart.
 Neighbour 3:
 Address: 192.168.30.1
 Routerid: 13.13.13.13
 Received Grace period: 250(in seconds).
 Actual Grace period: 250(in seconds).
 Remaining GraceTime: 245(in seconds).
 Graceful Restart reason: Software restart.
 Neighbour 4:
 Address: 192.168.40.1
 Routerid: 13.13.13.13
 Received Grace period: 250(in seconds).
 Actual Grace period: 250(in seconds).
 Remaining GraceTime: 245(in seconds).
 Graceful Restart reason: Software restart.

Productos afectados

Enterprise SONiC Distribution, PowerSwitch N3000 Series, PowerSwitch S5212F-ON, PowerSwitch S5224F-ON, PowerSwitch S5232F-ON, PowerSwitch S5248F-ON, PowerSwitch S5296F-ON, PowerSwitch Z9264F-ON, PowerSwitch Z9332F-ON
Propiedades del artículo
Número del artículo: 000218990
Tipo de artículo: How To
Última modificación: 29 feb 2024
Versión:  1
Encuentre respuestas a sus preguntas de otros usuarios de Dell
Servicios de soporte
Compruebe si el dispositivo está cubierto por los servicios de soporte.