Skip to content
Ask AI

OSPFv2 Configuration

[Command]

**show ip ospf ** [vrf NAME |all] [json]

[Purpose]

Display OSPF details

[View]

System view

[Use Cases]

sonic# show ip ospf vrf all json
{
"ospfInstance":2,
"1":{
"vrfName":"1",
"vrfId":138,
"routerId":"2.2.2.1",
"tosRoutesOnly":true,
"rfc2328Conform":true,
"spfScheduleDelayMsecs":0,
"holdtimeMinMsecs":50,
"holdtimeMaxMsecs":5000,
"holdtimeMultplier":1,
"spfLastExecutedMsecs":167987,
"spfLastDurationMsecs":0,
"lsaMinIntervalMsecs":5000,
"lsaMinArrivalMsecs":1000,
"writeMultiplier":20,
"refreshTimerMsecs":10000,
"lsaExternalCounter":0,
"lsaExternalChecksum":0,
"lsaAsopaqueCounter":0,
"lsaAsOpaqueChecksum":0,
"attachedAreaCounter":1,
"areas":{
"3.1.1.1":{
"shortcuttingMode":"Default",
"areaIfTotalCounter":1,
"areaIfActiveCounter":1,
"nbrFullAdjacentCounter":1,
"authentication":"authenticationNone",
"virtualAdjacenciesPassingCounter":0,
"spfExecutedCounter":8,
"lsaNumber":3,
"lsaRouterNumber":2,
"lsaRouterChecksum":74376,
"lsaNetworkNumber":1,
"lsaNetworkChecksum":45432,
"lsaSummaryNumber":0,
"lsaSummaryChecksum":0,
"lsaAsbrNumber":0,
"lsaAsbrChecksum":0,
"lsaNssaNumber":0,
"lsaNssaChecksum":0,
"lsaOpaqueLinkNumber":0,
"lsaOpaqueLinkChecksum":0,
"lsaOpaqueAreaNumber":0,
"lsaOpaqueAreaChecksum":0
}
}
}
}

[Command]

**show ip ospf ** [vrf NAME |all] **interface **[ethernet interface_name |vlan vlan_id |link-aggregation lag_id ]

[Purpose]

Show state and configuration of OSPF the specified interface, or all interfaces if no interface is given.

[Parameter]

ParameterDescription
interface_nameEthernet interface name (0..54)
vlan_idVLAN id (1..4094)
lag_idLink-aggregation interface number

[View]

System view

[Use Cases]

sonic# show ip ospf vrf 1 interface vlan 20
OSPF Instance: 2
VRF Name: 1
Vlan20 is up
ifindex 113, MTU 9216 bytes, BW 10 Mbit <UP,BROADCAST,RUNNING,ALLMULTI,MULTICAST>
Internet Address 20.1.1.1/24, Broadcast 20.1.1.255, Area 3.1.1.1
MTU mismatch detection: enabled
Router ID 2.2.2.1, Network Type BROADCAST, Cost: 10000
Transmit Delay is 1 sec, State Backup, Priority 1
Designated Router (ID) 2.2.2.2 Interface Address 20.1.1.2/24
Backup Designated Router (ID) 2.2.2.1, Interface Address 20.1.1.1
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
Hello due in 3.869s
Neighbor Count is 1, Adjacent neighbor count is 1

[Command]

**show ip ospf ** [vrf NAME |all] **neighbor ** [ethernet interface_name |vlan vlan_id |link-aggregation lag_id | A.B.C.D ][detail][all][json]

[Purpose]

Display lsa information of LSDB. Json o/p of this command covers base route information i.e all LSAs except opaque lsa info

[Parameter]

ParameterDescription
interface_nameEthernet interface name (0..54)
vlan_idVLAN id (1..4094)
lag_idLink-aggregation interface number
A.B.C.DIP address

[View]

System view

[Use Cases]

sonic# show ip ospf vrf all neighbor
OSPF Instance: 2
VRF Name: 1
Neighbor ID Pri State Up Time Dead Time Address Interface RXmtL RqstL DBsmL
2.2.2.2 1 Full/DR 14m07s 32.466s 20.1.1.2 Vlan20:20.1.1.1 0 0 0

show ip ospf database {max-age|self-originate}

Section titled “show ip ospf database {max-age|self-originate}”

[Command]

**show ip ospf ** [vrf { NAME |all| instance }] database max-age {max- age|self-originate}

[Purpose]

Show the OSPF database summary.

[Parameter]

ParameterDescription
NAMEVRF name
instanceInstance ID (1..65535)

[View]

System view

[Use Cases]

sonic# show ip ospf vrf all database max-age

show ip ospf database {opaque-link|opaque-area|opaque-external}

Section titled “show ip ospf database {opaque-link|opaque-area|opaque-external}”

[Command]

**show ip ospf ** [vrf { NAME |all| instance }] database{ opaque-link|opaque-area|opaque-external} [ A.B.C.D ][adv-router A.B.C.D ][self-originate]

[Purpose]

Show opaque LSA from the database.

[Parameter]

ParameterDescription
NAMEVRF name
instanceInstance ID (1..65535)
A.B.C.DIP address

[View]

System view

[Use Cases]

sonic# show ip ospf database opaque-link

[Command]

**show ip ospf ** [vrf NAME |all] route [json]

[Purpose]

Show the OSPF routing table, as determined by the most recent SPF calculation..

[View]

System view

[Use Cases]

sonic# show ip ospf vrf all route
OSPF Instance: 2
VRF Name: 1
============ OSPF network routing table ============
N 20.1.1.0/24 [10000] area: 3.1.1.1
directly attached to Vlan20
============ OSPF router routing table =============
============ OSPF external routing table ===========

[Command] show ip ospf router-info [pce]

[Purpose]

Show router capabilities flag

[View]

System view

[Use Cases]

sonic# show ip ospf router-info pce

[Command]

**router ospf ** [instance id ] [vrf NAME ]

**no router ospf ** [instance id ]

[Purpose] Enable or disable the OSPF process

[Parameter]

ParameterDescription
NAMEVRF name
instance idOSPF instance id, the range of value: 1-65535

[Usage Scenario] OSPF supports multiple instances, allowing a single router to run several independent OSPF instances that do not interfere with one another. These instances operate independently, and route exchanges between different OSPF instances are analogous to route exchanges between different routing protocols. Each router interface can belong to only one OSPF process.

[Notes] OSPF supports up to 10 instances on a single router.

[View]

System configuration view

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)#

[Command]

ospf router-id A.B.C.D

no ospf router-id A.B.C.D

[Purpose]

This sets the router-ID of the OSPF process.

[Parameter]

ParameterDescription
A.B.C.DOSPF router-id in IP address format

[View]

OSPF view

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# ospf router-id 1.1.1.1

[Command]

ospf rfc1583compatibility

no ospf rfc1583compatibility

[Purpose]

RFC 2328, the successor to RFC 1583, suggests according to section G.2 (changes) in section 16.4 a change to the path preference algorithm that prevents possible routing loops that were possible in the old version of OSPFv2. More specifically it demands that inter-area paths and intra-area backbone path are now of equal preference but still both preferred to external paths.

[View]

OSPF view

[Notes] This command disables OPSF rfc1583compatibility.

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# ospf rfc1583compatibility

[Command]

network A.B.C.D/M area { A.B.C.D | area_id }

no network A.B.C.D/M area { A.B.C.D | area_id }

[Purpose]

This command specifies the OSPF enabled interface(s).

[Parameter]

ParameterDescription
A.B.C.D/Mnetwork address
A.B.C.DOSPF router-id
area_idarea_id

[View]

OSPF view

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# network 1.1.1.1/24 area 11

[Command]

area { A.B.C.D | area_id } range A.B.C.D/M [**advertise ** [cost metric ]]

no area { A.B.C.D | area_id } range A.B.C.D/M [**advertise ** [cost metric ]]

[Purpose]

Summarize intra area paths from specified area into one Type-3 summary-LSA announced to other areas.

[Parameter]

ParameterDescription
A.B.C.D/Mnetwork address
A.B.C.Dospf router-id
area_idAREA ID
metricadvertised metric for this range (0..16777215)

[View]

OSPF view

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# area 1.1.1.1 range 1.1.1.1/32 advertise cost 100

[Command]

area { A.B.C.D | area_id } range A.B.C.D/M {substitute A.B.C.D/M |cost metric }

no area { A.B.C.D | area_id } range A.B.C.D/M {substitute A.B.C.D/M |cost metric }

[Purpose]

Substitute summarized prefix with another prefix

[Parameter]

ParameterDescription
A.B.C.D/Mnetwork address
area_idAREA ID
metricadvertised metric for this range (0..16777215)

[View]

OSPF view

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# area 1.1.1.1 range 1.1.1.1/32 advertise cost 100

[Command]

area { A.B.C.D | area_id } {stub|nssa} [no-summary]

no area { A.B.C.D | area_id } {stub|nssa} [no-summary]

[Purpose]

Prevents an OSPF ABR from injecting inter-area summaries into the specified stub area

[Parameter]

ParameterDescription
A.B.C.DOSPF router-id
area_idarea_id

[View]

OSPF view

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# area 1.1.1.1 stub no-summary

[Command]

**ip ospf area ** [instance ID ] { A.B.C.D | area_id } [ A.B.C.D ]

**no ip ospf area ** [instance ID ] { A.B.C.D | area_id } [ A.B.C.D ]

[Purpose]

Enable OSPF on the interface, optionally restricted to just the IP address given by ADDR, putting it in the AREA area.

[Parameter]

ParameterDescription
A.B.C.DOSPF router-id
area_idarea_id
A.B.C.DAddress of interface
instance IDOSPF instance ID

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf area 1.1.1.1 2.2.2.2

[Command]

ip ospf authentication-key KEY [ A.B.C.D ]

no ip ospf authentication-key KEY [ A.B.C.D ]

[Purpose]

Set OSPF authentication key to a simple password. After setting AUTH_KEY, all OSPF packets are authenticated. AUTH_KEY has length up to 8 chars.

[Parameter]

ParameterDescription
KEYThe OSPF password (key)
A.B.C.DAddress of interface

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf authentication-key test123 1.1.1.1

[Command]

**ip ospf authentication ** [message-digest] [ A.B.C.D ]

**no ip ospf authentication ** [message-digest] [ A.B.C.D ]

[Purpose]

Specify that MD5 HMAC authentication must be used on this interface

[Parameter]

ParameterDescription
A.B.C.DAddress of interface

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf authentication message-digest 1.1.1.1

[Command] ip ospf message-digest-key KEY_ID md5 MD5 [ A.B.C.D ]

no ip ospf message-digest-key KEY_ID md5 MD5 [ A.B.C.D ]

[Purpose]

Set OSPF authentication key to a cryptographic password. The cryptographic algorithm is MD5.

[Parameter]

ParameterDescription
KEY_IDKey ID (1..255)
MD5Use MD5 algorithm
A.B.C.DAddress of interface

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf message-digest-key 2 md5 s 1.1.1.1

[Command]

ip ospf cost COST [ A.B.C.D ]

no ip ospf cost COST [ A.B.C.D ]

[Purpose]

Set link cost for the specified interface.

[Parameter]

ParameterDescription
COSTCost (1..65535)
A.B.C.DAddress of interface

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf cost 12

[Command]

ip ospf dead-interval { interval |minimal hello-multiplier number } [ A.B.C.D ] no ip ospf dead-interval { interval |minimal hello-multiplier number } [ A.B.C.D ]

[Purpose]

Set interface’s router dead interval. Default value is 40.

[Parameter]

ParameterDescription
intervalSeconds (1..65535)
numberNumber of Hellos to send each second (1..10)
A.B.C.DAddress of interface

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf dead-interval 2 1.1.1.1

[Command]

ip ospf hello-interval interval [A.B.C.D ]

no ip ospf hello-interval interval [ A.B.C.D ]

[Purpose] Set interface’s hello interval. Default 10.

[Parameter]

ParameterDescription
IntervalSeconds (1..65535)
A.B.C.DAddress of interface

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf hello-interval 2 1.1.1.1

[Command]

ip ospf network {broadcast|non-broadcast|point-to-multipoint|point-to-point}

no ip ospf network {broadcast|non-broadcast|point-to- multipoint|point-to-point}

[Purpose]

Set explicitly network type for specified interface.

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf network broadcast

[Command]

ip ospf priority priority [A.B.C.D ] no ip ospf priority priority [ A.B.C.D ]

[Purpose]

Set router priority integer value.

[Parameter]

ParameterDescription
priorityPriority (0..255)
A.B.C.DAddress of interface

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf priority 12

[Command]

ip ospf retransmit-interval interval [ A.B.C.D ]

no ip ospf retransmit-interval interval [ A.B.C.D ]

[Purpose]

Set number of seconds for RxmtInterval timer value

[Parameter]

ParameterDescription
intervalSeconds (1..65535)
A.B.C.DAddress of interface

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf retransmit-interval 2

[Command]

ip ospf transmit-delay interval [ A.B.C.D ]

no ip ospf transmit-delay interval [ A.B.C.D ]

[Purpose]

Set number of seconds for InfTransDelay value.

[Parameter]

ParameterDescription
intervalSeconds (1..65535)
A.B.C.DAddress of interface

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf retransmit-interval 2

[Command]

ip ospf mtu-ignore

no ip ospf mtu-ignore

[Purpose]

Ignore MTU when establish OSPF

[View]

Interface view

[Use Cases]

sonic# configure terminal
sonic(config)# interface ethernet 49
sonic(config-if-49)# ip ospf mtu-ignore

[Command]

redistribute {babel|bgp|connected|eigrp|isis|kernel|openfabric|ospf|rip|sharp|static|table} [metric-type metric_type ] [metric metric ] [route-map route_map ]

no redistribute {babel|bgp|connected|eigrp|isis|kernel|openfabric|ospf|rip|sharp|static|table} [metric-type metric_type ] [metric metric ] [route-map route_map ]

[Purpose]

Redistribute routes of the specified protocol or kind into OSPF, with the metric type and metric set if specified, filtering the routes using the given route-map if specified.

[Parameter]

ParameterDescription
metric_typeSet OSPF External Type 1/2 metrics (1..2)
metricOSPF default metric (0..16777214)
route_mapPointer to route-map entries

[View]

OSPF view

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# redistribute static metric-type 1 metric 2 route-map test

[Command]

**default-information originate ** [always] [metric-type metric_type ][metric metric ] [route-map route_map ]

**no default-information originate ** [always] [metric-type metric_type ][metric metric ] [route-map route_map ]

[Purpose]

Originate an AS-External (type-5) LSA describing a default route into all external-routing capable areas, of the specified metric and metric type. If the ‘always’ keyword is given then the default is always advertised, even when there is no default present in the routing table.

[Parameter]

ParameterDescription
metric_typeSet OSPF External Type 1/2 metrics (1..2)
metricOSPF default metric (0..16777214)
route_mapPointer to route-map entries

[View]

OSPF view

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# default-information originate always

[Command]

distribute-list String out {babel|bgp|connected|eigrp|isis|kernel|openfabric|ospf|rip|sharp|static|table}

no distribute-list String out{ babel|bgp|connected|eigrp|isis|kernel|openfabric|ospf|rip|sharp|static|table}

[Purpose]

Apply the access-list filter, NAME, to redistributed routes of the given type before allowing the routes to be redistributed into OSPF

[View]

OSPF view

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# distribute-list test out static

[Command]

default-metric metric

no default-metric metric

[Purpose]

Set default metric

[Parameter]

ParameterDescription
metricOSPF default metric (0..16777214)

[View]

OSPF view

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# default-metric 2

[Command]

distance [ospf {intra-area|inter-area|external}] distance

no distance [ospf {intra-area|inter-area|external}] distance

[Purpose]

Set OSPF distance

[Parameter]

ParameterDescription
distanceDistance for external routes (1..255)

[View]

OSPF view

[Use Cases]

sonic# configure terminal
sonic(config)# router ospf
sonic(config-router)# distance ospf external 2