---
title: OSPF
slug: aidc/ospf
createdAt: 2025-12-01T11:11:08.000Z
---

## <font color="#1d50a2">OSPF View</font>

<font color="#1d05a2">Table 1 OSPF View</font>

| **Command**                                                                   | **Purpose**                                         |
| ----------------------------------------------------------------------------- | --------------------------------------------------- |
| **show ip ospf neighbor** \[*OPTIONs*]                                        | Display OSPF neighbor information                   |
| **show ip ospf route**                                                        | Display OSPF route information                      |
| **show ip ospf datebase**                                                     | Display OSPF datebase information                   |
| **show ip ospf vrf** *vrf\_name* **neighbor** \[*OPTIONs*]                    | Display OSPF neighbor information for specified VRF |
| **show ip ospf interface \[ethernet\|vlan\|link-aggregation\|traffic\|json]** | Display OSPF neighbor information for the interface |

### <font color="#1d50a2">show ip ospf neighbor \[*OPTIONs*\]</font>

**\[Command]**
**show ip ospf neighbor** \[*OPTIONs*]

**\[Purpose]**
Display OSPF neighbor information.

**\[Options]**

| **Option**           | **Description**                                          |
| -------------------- | -------------------------------------------------------- |
| **all**              | Display all OSPF neighbor information.                   |
| **json**             | Display in Json format.                                  |
| **detail**           | Display neighbor details.                                |
| *A.B.C.D*            | Display neighbor information based on neighbor ID.       |
| **ethernet**         | Display neighbor information for physical interface.     |
| **vlan**             | Display neighbor information for VLAN interface.         |
| **link-aggregation** | Display neighbor information for aggregation interfaces. |

**\[View]**
Privileged User View

**\[Use Cases]**

```plaintext
sonic# show ip ospf neighbor
Neighbor ID     Pri State           Up Time         Dead Time Address         Interface                        RXmtL RqstL DBsmL
40.0.0.         1 Full/DR         2m16s             32.582s 40.0.0.2        ethernet 0/40:40.0.0.1                  0     0     0
```

### <font color="#1d50a2">show ip ospf route</font>

**\[Command]**
**show ip ospf route**

**\[Purpose]**
Display OSPF route information.

**\[View]**
Privileged User View

**\[Use Cases]**

```plaintext
sonic# show ip ospf route
============ OSPF network routing table ============
N    40.0.0.0/24           [10000] area: 0.0.0.10
                           directly attached to ethernet 0/40
============ OSPF router routing table =============
============ OSPF external routing table ===========
```

### <font color="#1d50a2">show ip ospf database</font>

**\[Command]**
**show ip ospf database**

**\[Purpose]**
Display OSPF database information.

**\[View]**
Privileged User View

**\[Use Cases]**

```plaintext
sonic# show ip ospf database
       OSPF Router with ID (40.0.0.1)
                Router Link States (Area 0.0.0.10)
Link ID         ADV Router      Age  Seq#       CkSum  Link count
40.0.0.1       40.0.0.1        1062 0x8000003c 0x71ca 1
200.0.0.1      200.0.0.1       1063 0x80000003 0x240f 1
                Net Link States (Area 0.0.0.10)
Link ID         ADV Router      Age  Seq#       CkSum
40.0.0.2       200.0.0.1       1063 0x80000001 0x2053
```

### <font color="#1d50a2">show ip ospf vrf *vrf\_name* neighbor \[*OPTIONs*\]</font>

**\[Command]**
**show ip ospf vrf** *vrf\_name* **neighbor** \[*OPTIONs*]

**\[Purpose]**
Display OSPF neighbor information for specified VRF.

**\[Parameters]**

| **Parameter** | **Description** |
| ------------- | --------------- |
| *vrf\_name*   | Vrf name.       |

**\[Options]**

| **Option**           | **Description**                                          |
| -------------------- | -------------------------------------------------------- |
| **all**              | Display all OSPF neighbor information.                   |
| **json**             | Display in Json format.                                  |
| **detail**           | Display neighbor details.                                |
| **A.B.C.D**          | Display neighbor information based on neighbor ID.       |
| **ethernet**         | Display neighbor information for physical interface.     |
| **vlan**             | Display neighbor information for VLAN interface.         |
| **link-aggregation** | Display neighbor information for aggregation interfaces. |

**\[View]**
Privileged User View

**\[Use Cases]**

```plaintext
sonic# show ip ospf vrf 100 neighbor
VRF Name: Vrf100
Neighbor ID     Pri State           Up Time         Dead Time Address         Interface                        RXmtL RqstL DBsmL
40.0.0.2          1 Full/Backup     3.521s            36.996s 40.0.0.2        ethernet 0/40:40.0.0.1                  1     0     0
```

### <font color="#1d50a2">show ip ospf interface \[ethernet|vlan|link-aggregation|traffic|json\]</font>

**\[Command]**
**show ip ospf interface \[ethernet|vlan|link-aggregation|traffic|json]**
**\[Purpose]**
Display OSPF neighbor information for the interface.

**\[Parameters]**

| **Parameter**        | **Description**                                          |
| -------------------- | -------------------------------------------------------- |
| **ethernet**         | Display neighbor information for physical interfaces.    |
| **vlan**             | Display neighbor information for VLAN interfaces.        |
| **link-aggregation** | Display neighbor information for aggregation interfaces. |
| **traffic**          | Display OSPF message count for interface.                |
| **json**             | Display interface neighbor information in JSON format.   |

**\[View]**
Privileged User View

**\[Use Cases]**

```plaintext
sonic# show ip ospf interface
ethernet 0/40 is up
  ifindex 57, MTU 9216 bytes, BW 10 Mbit <UP,BROADCAST,RUNNING,ALLMULTI,MULTICAST>
  Internet Address 40.0.0.1/24, Broadcast 40.0.0.255, Area 0.0.0.10
  MTU mismatch detection: enabled
  Router ID 1.1.1.1, Network Type BROADCAST, Cost: 10000
  Transmit Delay is 1 sec, State Backup, Priority 1
  Designated Router (ID) 200.0.0.1 Interface Address 40.0.0.2/24
  Backup Designated Router (ID) 1.1.1.1, Interface Address 40.0.0.1
  Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    Hello due in 1.825s
  Neighbor Count is 1, Adjacent neighbor count is 1
  BFD: Detect Multiplier: 3, Min Rx interval: 300, Min Tx interval: 300
```

## <font color="#1d50a2">OSPF Config</font>

<font color="#1d05a2">Table 2 OSPF Config</font>

| **Command**                                                                                               | **Purpose**                                             |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| **router *ospf\_type*** \[***vrf\_name***]                                                                | Enable OSPF.                                            |
| **ospf router-id** *A.B.C.D*                                                                              | Configure the router ID for OSPF.                       |
| **area *area\_id*** \{**authentication**\|**default-cost**\|**nssa**\|**stub**}                           | Configure area related parameters.                      |
| **auto-cost reference-bandwidth** *bandwidth*                                                             | Configure auto-cost reference bandwidth.                |
| **redistribute** *src\_protocol* \[**metric** *metric\_value*\|**route-map** *route\_map*]                | Introducing routing for other protocols.                |
| **ip ospf area** *area\_id*                                                                               | Enable OSPF function of the interface.                  |
| **ip ospf network&#x20;**\{**broadcast**\|**non-broadcast**\|**point-to-multipoint**\|**point-to-point**} | Configure OSPF network type.                            |
| **ip ospf cost** *number*                                                                                 | Configure cost value.                                   |
| **ip ospf priority** *priority*                                                                           | Configure OSPF router priority.                         |
| **ip ospf mtu-ignore**                                                                                    | Enable MTU ignore switch.                               |
| **ip ospf&#x20;**\{**dead-interval**\|**hello-interval**\|**retransmit-interval**} *time*                 | Configure OSPF various time intervals.                  |
| **ip ospf authentication** \[**null\|message-digest]**                                                    | Configure OSPF interface authentication method.         |
| **ip ospf authentication-key** *auth-key*                                                                 | Configure passwords for simple password authentication. |
| **ip ospf message-digest-key** *key-id***&#x20;md5** *key*                                                | Configure password for MD5 authentication.              |
| **ip ospf bfd&#x20;**\[**profile&#x20;***profile\_name*]                                                  | Configure OSPF and BFD linkage.                         |
| **ip ospf ttl** *ttl\_value*                                                                              | Set the TTL value of OSPF message.                      |

### <font color="#1d50a2">router *ospf\_type* \[*vrf\_name*\]</font>

**\[Command]**
**router** *ospf\_type* \[*vrf\_name*]

**\[Purpose]**
Enable OSPF and enter the OSPF configuration view.

**\[Parameters]**

| **Parameter** | **Description**                                                 |
| ------------- | --------------------------------------------------------------- |
| *ospf\_type*  | The type of OSPF is ospf or ospf6, which is either IPv4 or IPv6 |
| *vrf\_name*   | VRF name, default VRF if not specified                          |

**\[View]**
Global Configuration View

**\[Notes]**
Run command **no router ospf \[*vrf\_name*]** to disable OSPF function.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# router ospf
```

### <font color="#1d50a2">ospf router-id *A.B.C.D*</font>

**\[Command]**
**ospf router-id** *A.B.C.D*

**\[Purpose]**
Configure router ID.

**\[Parameters]**

| **Parameter** | **Description** |
| ------------- | --------------- |
| *A.B.C.D*     | router id       |

**\[View]**
OSPF Configuration View

**\[Notes]**
Run command **no ospf** router-id *A.B.C.D* delete OSPF router id

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# router ospf
sonic(config-router)# ospf router-id 1.1.1.1
```

### <font color="#1d50a2">area *area\_id* \{authentication|default-cost|nssa|stub\}</font>

**\[Command]**
**area** *area\_id* \{**authentication|default-cost|nssa|stub**}

**\[Purpose]**
Configure area related parameters.

**\[Parameters]**

| **Parameter**      | **Description**                                                                                      |
| ------------------ | ---------------------------------------------------------------------------------------------------- |
| area\_id           | area id                                                                                              |
| **authentication** | Set the area authentication as short answer password authentication or MD5 encryption authentication |
| **default-cost**   | Set default cost for nssa or stub domains                                                            |
| **nssa**           | Configure OSPF area as nssa                                                                          |
| **stub**           | Configure OSPF area as stub                                                                          |

**\[View]**
OSPF Configuration View

**\[Notes]**
Run command no **area** *area\_id* **\{authentication| default-cost| nssa| stub}** to delete area related parameter configurations.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# router ospf
asonic(config-router)# area 10 stub
```

### <font color="#1d50a2">auto-cost reference-bandwidth *bandwidth*</font>

**\[Command]**
**auto-cost reference-bandwidth** *bandwidth*

**\[Purpose]**
Configure auto-cost reference bandwidth.

**\[Parameters]**

| **Parameter** | **Description**                                                               |
| ------------- | ----------------------------------------------------------------------------- |
| *bandwidth*   | Reference bandwidth value, the unit is Mb/s, with a value range of 1-4294967. |

**\[View]**
OSPF Configuration View

**\[Notes]**
Run command **no auto-cost reference-bandwidth** to delete configured reference bandwidth.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# router ospf
sonic(config-router)# auto-cost reference-bandwidth 10000
```

### <font color="#1d50a2">redistribute *src\_protocol* \[metric *metric\_value*|route-map *route-map*\]</font>

**\[Command]**
**redistribute** *src\_protocol* \[**metric** *metric\_value*|**route-map** *route-map*]

**\[Purpose]**
Redistribute information from another routing protocol in OSPF.

**\[Parameters]**

| **Parameter**   | **Description**                                                        |
| --------------- | ---------------------------------------------------------------------- |
| *src\_protocol* | Set source protocol (connected\|isis\|kernel\|ospf\|rip\|static\|bgp). |
| *metric\_value* | Metric for redistributed routes, range from 0 to 16777214.             |
| *route-map*     | Route map reference.                                                   |

**\[View]**
OSPF Configuration View

**\[Notes]**
The redistribution for the same protocol is an overriding configuration.
Run command **no redistribute** *src\_protocol* \[**metric** *metric\_value*|**route-map** *route-map*] to cancel route redistribution.

**\[Use Cases]**

```plaintext
sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# redistribute connected metric 100
```

### <font color="#1d50a2">ip ospf area *area\_id*</font>

**\[Command]**
**ip ospf area** *area\_id*

**\[Purpose]**
Enable OSPF function of the interface.

**\[Parameters]**

| **Parameter** | **Description**                                                                                              |
| ------------- | ------------------------------------------------------------------------------------------------------------ |
| *area\_id*    | area id, it is an IP address or decimal form. If it is a decimal value, the range of values is 0\~4294967295 |

**\[View]**
Physical interface/VLAN interface/LAG interface configuration view

**\[Notes]**
Run command **no ip ospf area** *area\_id* to disable OSPF function of the interface.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/40
sonic(config-if-0/40)# ip ospf area 10
```

### <font color="#1d50a2">ip ospf network \{broadcast|non-broadcast|point-to-multipoint|point-to-point\}</font>

**\[Command]**
**ip ospf network \{broadcast|non-broadcast|point-to-multipoint|point-to-point}**

**\[Purpose]**
Configure OSPF network type.

**\[View]**
Physical interface/VLAN interface/LAG interface configuration view

**\[Notes]**
Run command **no ip ospf network** to not specify the network type for OSPF, the default network type is broadcast.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/40
sonic(config-if-0/40)# ip ospf network point-to-point
```

### <font color="#1d50a2">ip ospf cost *number*</font>

**\[Command]**
**ip ospf cost** *number*

**\[Purpose]**
Configure the cost value of OSPF network ports.

**\[Parameters]**

| **Parameter** | **Description**                         |
| ------------- | --------------------------------------- |
| *number*      | Cost value, the value range is 1\~65535 |

**\[View]**
Physical interface/VLAN interface/LAG interface configuration view

**\[Notes]**
Run command **no ip ospf cost** to delete the cost value of the interface.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/40
sonic(config-if-0/40)# ip ospf cost 100
```

### <font color="#1d50a2">ip ospf priority *priority*</font>

**\[Command]**
**ip ospf priority** *priority*

**\[Purpose]**
Configure OSPF router priority.

**\[Parameters]**

| **Parameter** | **Description**                                              |
| ------------- | ------------------------------------------------------------ |
| *priority*    | Priority level, range of values is 0-255, default level is 1 |

**\[View]**
Physical interface/VLAN interface/LAG interface configuration view

**\[Notes]**
Run command **no ip ospf priority** to restore OSPF router priority to default value.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/40
sonic(config-if-0/40)# ip ospf priority 10
```

### <font color="#1d50a2">ip ospf mtu-ignore</font>

**\[Command]**
**ip ospf mtu-ignore**

**\[Purpose]**
Enable MTU ignore switch.

**\[View]**
Physical interface/VLAN interface/LAG interface configuration view

**\[Notes]**
Run command **no ip ospf  mtu-ingore** to disable MTU ignore switch.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/40
sonic(config-if-0/40)# ip ospf mtu-ignore
```

### <font color="#1d50a2">ip ospf \{dead-interval|hello-interval|retransmit-interval\}</font>

**\[Command]**
**ip ospf \{dead-interval|hello-interval|retransmit-interval}**

**\[Purpose]**
Configure OSPF various time intervals.

**\[Parameters]**

| **Parameter**           | **Description**                                                                                                                |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| **dead-interval**       | Neighbor timeout interval, measured in seconds, with a range of 1 to 65535, default to 40 seconds                              |
| **hello-interval**      | The time interval for sending hello messages, measured in seconds, with a range of 1 to 65535. The default value is 10 seconds |
| **retransmit-interval** | The time interval for retransmitting LSA messages, measured in seconds, with a range of 1 to 65535, and a default of 5 seconds |

**\[View]**
Physical interface/VLAN interface/LAG interface configuration view

**\[Notes]**
Run command **no ip ospf \{dead-interval|hello-interval|retransmit-interval}** to restore various time intervals to default values.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/40
sonic(config-if-0/40)# ip ospf dead-interval 50
sonic(config-if-0/40)# ip ospf hello-interval 10
sonic(config-if-0/40)# ip ospf retransmit-interval 20
```

### <font color="#1d50a2">ip ospf authentication \[null|message-digest\]</font>

**\[Command]**
**ip ospf authentication \[null|message-digest]**
**\[Purpose]**
Configure OSPF interface authentication method.

**\[Parameters]**

| **Parameter**  | **Description**                                           |
| -------------- | --------------------------------------------------------- |
| null           | Configure authentication method as null authentication    |
| message-digest | Configure the authentication method to MD5 authentication |

**\[View]**
Physical interface/VLAN interface/LAG interface configuration view

**\[Notes]**
When there are no parameters, the authentication method is simple password authentication. When both regional authentication and interface authentication are configured, interface authentication is preferred.
Run command **no ip ospf authentication** to delete OSPF interface authentication.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/40
sonic(config-if-0/40)# ip ospf authentication
sonic(config-if-0/40)# ip ospf authentication message-digest
```

### <font color="#1d50a2">ip ospf authentication-key *auth-key*</font>

**\[Command]**
**ip ospf authentication-key** *auth-key*

**\[Purpose]**
Configure simple password authentication password.

**\[Parameters]**

| **Parameter** | **Description**                                                         |
| ------------- | ----------------------------------------------------------------------- |
| auth-key      | Authentication password, password length less than or equal to 8 digits |

**\[View]**
Physical interface/VLAN interface/LAG interface configuration view

**\[Notes]**
Run command **no ip ospf authentication** to delete password for simple password authentication.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/40
sonic(config-if-0/40)# ip ospf authentication-key 123456
```

### <font color="#1d50a2">ip ospf message-digest-key *key-id* md5 *key*</font>

**\[Command]**
**ip ospf message-digest-key** *key-id* **md5** *key*

**\[Purpose]**
Configure MD5 authentication password.

**\[Parameters]**

| **Parameter** | **Description**                                                                        |
| ------------- | -------------------------------------------------------------------------------------- |
| *key\_id*     | Key ID, with a value range of 1-255                                                    |
| *key*         | Password for MD5 authentication method, with a length of less than or equal to 16 bits |

**\[View]**
Physical interface/VLAN interface/LAG interface configuration view

**\[Notes]**
Run command **no ip ospf message-digest-key** *key\_id* **md5** *key* to delete password for MD5 authentication method.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/40
sonic(config-if-0/40)# ip ospf message-digest-key 10 md5 123456
```

### <font color="#1d50a2">ip ospf bfd \[profile *profile\_name*\]</font>

**\[Command]**
**ip ospf bfd** \[**profile** *profile\_name*]

**\[Purpose]**
Configure OSPF and BFD linkage.

**\[Parameters]**

| **Parameter**   | **Description**         |
| --------------- | ----------------------- |
| *profile\_name* | The profile name of BFD |

**\[View]**
Physical interface/VLAN interface/LAG interface configuration view

**\[Notes]**
Run command **no ip ospf bfd** to delete OSPF and BFD linkage.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/40
sonic(config-if-0/40)# ip ospf bfd sw1
```

### <font color="#1d50a2">ip ospf ttl *ttl\_value*</font>

**\[Command]**
**ip ospfttl** *ttl\_value*

**\[Purpose]**
Set the TTL value of OSPF message.

**\[Parameters]**

| **Parameter** | **Description**                |
| ------------- | ------------------------------ |
| *ttl\_value*  | TTL value, the range is 0\~255 |

**\[View]**
Physical interface/VLAN interface/LAG interface configuration view

**\[Notes]**
Run command **no ip ospf ttl** to restore to the default value.
The default TTL is 1.

**\[Use Cases]**

```plaintext
sonic# configure
sonic(config)# interface ethernet 0/40
sonic(config-if-0/40)# ip ospf ttl 10
```

