Skip to content

OSPF

OSPF (Open Shortest Path First) is a standards-based link-state interior gateway protocol that uses Dijkstra’s shortest path first algorithm to calculate optimal routes through a network topology stored in a synchronized link-state database. It provides fast convergence, load balancing across equal-cost paths, and hierarchical network design through area-based segmentation that reduces routing overhead and improves scalability in large networks. OSPF supports advanced features including route summarization, authentication, traffic engineering extensions, and integration with MPLS for comprehensive enterprise and service provider routing solutions.

Diagram
NameTypeConstraintMandatoryDefault Value
ospf_processesList[ospf_processes]No

ospf_processes (iosxe.devices.configuration.routing)

Section titled “ospf_processes (iosxe.devices.configuration.routing)”
NameTypeConstraintMandatoryDefault Value
idIntegermin: 1, max: 65535No
vrfStringNo
bfd_all_interfacesBooleantrue, falseNo
default_information_originateBooleantrue, falseNo
default_information_originate_alwaysBooleantrue, falseNo
default_information_originate_metricIntegermin: 1, max: 16777214No
default_information_originate_metric_typeIntegermin: 1, max: 2No
default_information_originate_route_mapStringNo
default_metricIntegermin: 1, max: 16777214No
distanceIntegermin: 1, max: 255No
domain_tagIntegermin: 1, max: 4294967295No
fast_reroute_per_prefix_enable_prefix_priorityChoicehigh, lowNo
log_adjacency_changesBooleantrue, falseNo
log_adjacency_changes_detailBooleantrue, falseNo
max_metric_router_lsaBooleantrue, falseNo
max_metric_router_lsa_external_lsa_metricIntegermin: 1, max: 16777215No
max_metric_router_lsa_include_stubBooleantrue, falseNo
max_metric_router_lsa_on_startup_timeIntegermin: 5, max: 86400No
max_metric_router_lsa_on_startup_wait_for_bgpBooleantrue, falseNo
max_metric_router_lsa_summary_lsa_metricIntegermin: 1, max: 16777215No
mpls_ldp_autoconfigBooleantrue, falseNo
mpls_ldp_syncBooleantrue, falseNo
neighborsList[neighbors]No
networksList[networks]No
nsf_ciscoBooleantrue, falseNo
nsf_cisco_enforce_globalBooleantrue, falseNo
nsf_ietfBooleantrue, falseNo
nsf_ietf_restart_intervalIntegermin: 1, max: 3600No
priorityIntegermin: 0, max: 127No
redistributeClass[redistribute]No
router_idIPNo
shutdownBooleantrue, falseNo
summary_addressesList[summary_addresses]No
areasList[areas]No
passive_interface_defaultBooleantrue, falseNo
auto_cost_reference_bandwidthIntegermin: 1, max: 4294967No
passive_interfacesList[passive_interfaces]No
non_passive_interfacesList[non_passive_interfaces]No
distribute_list_inStringNo
distribute_list_outStringNo

neighbors (iosxe.devices.configuration.routing.ospf_processes)

Section titled “neighbors (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
ipIPYes
priorityIntegermin: 0, max: 255No
costIntegermin: 1, max: 65535No

networks (iosxe.devices.configuration.routing.ospf_processes)

Section titled “networks (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
ipIPYes
wildcardIPNo
areaAnyString or Integer[min: 0]No

redistribute (iosxe.devices.configuration.routing.ospf_processes)

Section titled “redistribute (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
connectedBooleantrue, falseNo
connected_metricIntegermin: 0, max: 16777214No
connected_metric_typeIntegermin: 1, max: 2No
connected_route_mapStringNo
connected_tagIntegermin: 0, max: 4294967295No
staticBooleantrue, falseNo
static_metricIntegermin: 0, max: 16777214No
static_metric_typeIntegermin: 1, max: 2No
static_route_mapStringNo
static_tagIntegermin: 0, max: 4294967295No
ospfList[ospf]No

summary_addresses (iosxe.devices.configuration.routing.ospf_processes)

Section titled “summary_addresses (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
ipIPYes
maskIPNo

areas (iosxe.devices.configuration.routing.ospf_processes)

Section titled “areas (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
idAnyString or Integer[min: 0]No
authentication_message_digestBooleantrue, falseNo
nssaBooleantrue, falseNo
nssa_default_information_originateBooleantrue, falseNo
nssa_default_information_originate_metricIntegermin: 0, max: 16777214No
nssa_default_information_originate_metric_typeIntegermin: 1, max: 2No
nssa_no_summaryBooleantrue, falseNo
nssa_no_redistributionBooleantrue, falseNo

passive_interfaces (iosxe.devices.configuration.routing.ospf_processes)

Section titled “passive_interfaces (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
interface_typeChoiceLoopback, Vlan, GigabitEthernet, TwoGigabitEthernet, FiveGigabitEthernet, TenGigabitEthernet, TwentyFiveGigabitEthernet, FortyGigabitEthernet, FiftyGigabitEthernet, HundredGigabitEthernetNo
interface_idAnyString or Integer[min: 0]No

non_passive_interfaces (iosxe.devices.configuration.routing.ospf_processes)

Section titled “non_passive_interfaces (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
interface_typeChoiceLoopback, Vlan, Tunnel, Port-channel, Port-channel-subinterface, GigabitEthernet, TwoGigabitEthernet, FiveGigabitEthernet, TenGigabitEthernet, TwentyFiveGigabitEthernet, FortyGigabitEthernet, HundredGigabitEthernet, TwoHundredGigabitEthernet, FourHundredGigabitEthernetNo
interface_idAnyString or Integer[min: 0]No

ospf (iosxe.devices.configuration.routing.ospf_processes.redistribute)

Section titled “ospf (iosxe.devices.configuration.routing.ospf_processes.redistribute)”
NameTypeConstraintMandatoryDefault Value
process_idIntegermin: 1, max: 65535Yes
match_internalBooleantrue, falseNo
match_external_1Booleantrue, falseNo
match_external_2Booleantrue, falseNo
match_nssa_external_1Booleantrue, falseNo
match_nssa_external_2Booleantrue, falseNo
metricIntegermin: 0, max: 16777214No
metric_typeIntegermin: 1, max: 2No
route_mapStringNo
tagIntegermin: 0, max: 4294967295No
vrfStringNo

By using Dijkstra’s algorithm and area-based segmentation, OSPF provides fast convergence, scalable routing, and robust network design.

Key Components:

  • OSPF Process ID (id): Identifies the OSPF routing process.

  • Router ID (router_id): Sets the unique router ID for the process.

  • Network Statements (networks): Advertises networks into OSPF with IP, wildcard mask, and area.

  • Area Type (areas): Configures area types (normal, stub, NSSA, totally stubby).

  • Interface Cost (neighbors.cost): Sets the cost for OSPF interfaces.

  • Interface Priority (neighbors.priority): Sets the priority for OSPF interfaces.

  • Authentication (areas.authentication_message_digest): Enables OSPF authentication (simple, MD5).

  • Default Information Originate (default_information_originate): Advertises a default route into OSPF. Supports default_information_originate_metric, default_information_originate_metric_type (1 or 2), and default_information_originate_route_map.

  • Redistribute (redistribute): Controls route redistribution into OSPF. Supports static and connected with optional metric, metric_type, route_map, and tag. Inter-process OSPF redistribution via ospf list with process_id, match options (match_internal, match_external_1, match_external_2), and common redistribution attributes.

  • Distribute List (distribute_list_in, distribute_list_out): Filters OSPF routing updates using a standard ACL applied inbound or outbound.

  • Route Summarization (summary_addresses): Configures inter-area and external route summarization.

  • Administrative Distance (distance): Sets the OSPF administrative distance.

  • Bidirectional Forwarding Detection (BFD) (bfd_all_interfaces): Enables BFD for OSPF interfaces.

  • Passive Interface (passive_interface_default, passive_interfaces, non_passive_interfaces): Configures passive interfaces. Use passive_interface_default with non_passive_interfaces to enable the common hardening pattern of making all interfaces passive by default and selectively re-enabling specific uplinks.

  • Reference Bandwidth (auto_cost_reference_bandwidth): Sets reference bandwidth for auto-cost calculation.

  • VRF Association (vrf): Associates OSPF process with a VRF.

Key Parameters Briefly Explained:

  • id: OSPF process identifier.
  • router_id: Unique router ID.
  • networks: Network statements for OSPF.
  • areas: Area configuration and types.
  • neighbors.cost, neighbors.priority: Interface cost and priority.
  • areas.authentication_message_digest: Authentication settings.
  • default_information_originate: Default route advertisement.
  • default_information_originate_metric, default_information_originate_metric_type: Default route metric options.
  • redistribute.static, redistribute.connected: Basic redistribution with optional metric, metric_type, route_map, tag.
  • redistribute.ospf: Inter-process OSPF redistribution with match options.
  • distribute_list_in, distribute_list_out: ACL-based route filtering.
  • summary_addresses: Route summarization.
  • distance: Administrative distance.
  • bfd_all_interfaces: BFD enablement.
  • passive_interface_default, passive_interfaces, non_passive_interfaces: Passive interface settings.
  • auto_cost_reference_bandwidth: Reference bandwidth.
  • vrf: VRF association.

You can use these OSPF parameters to design and implement a scalable and efficient routing infrastructure. Customize the process ID, router ID, network statements, area types, and interface settings to fit your network’s topology, performance requirements, and security policies. Adjusting these parameters lets you tailor OSPF’s behavior for optimal route calculation and distribution.

The following configuration describes how to set up OSPF on a Cisco IOS-XE device, including process definition, router ID, network advertisement, area configuration, default route origination, passive interfaces, and VRF association.

router ospf 100
router-id 192.168.1.1
bfd all-interfaces
redistribute connected metric 200 metric-type 2 tag 600
redistribute static metric 100 metric-type 1 tag 500 route-map RM_STATIC
redistribute ospf 200 metric 150 metric-type 1 match internal external 1
default-information originate always metric 10 metric-type 1
auto-cost reference-bandwidth 10000
network 192.168.1.0 0.0.0.255 area 0
network 10.0.0.0 0.255.255.255 area 1
distribute-list 10 in
distribute-list 20 out
passive-interface default
no passive-interface GigabitEthernet0/0
passive-interface Vlan100
area 1 authentication message-digest
area 1 nssa default-information-originate metric 100 metric-type 1 no-summary
!
router ospf 200 vrf VRF-PROD
router-id 172.16.1.1
default-metric 20
network 172.16.0.0 0.0.255.255 area 0

The following YAML code defines OSPF configuration on an IOS-XE device, including multiple OSPF processes, VRF association, BFD settings, default route origination, auto-cost reference bandwidth, neighbor configuration, networks, router ID, summary addresses, area types, and passive interface settings.

iosxe:
devices:
- name: Device1
configuration:
routing:
ospf_processes:
- id: 100
vrf: VRF-PROD
bfd_all_interfaces: true
default_information_originate: true
default_information_originate_always: true
default_metric: 10
distance: 120
domain_tag: 10
auto_cost_reference_bandwidth: 10000
neighbors:
- ip: 192.168.1.2
priority: 10
cost: 100
- ip: 192.168.2.2
priority: 5
cost: 50
networks:
- ip: 192.168.1.0
wildcard: 0.0.0.255
area: "0"
- ip: 10.0.0.0
wildcard: 0.255.255.255
area: "1"
router_id: 192.168.1.1
shutdown: false
summary_addresses:
- ip: 10.0.0.0
mask: 255.0.0.0
- ip: 172.16.0.0
mask: 255.240.0.0
areas:
- id: "1"
authentication_message_digest: true
nssa: true
nssa_default_information_originate: true
nssa_default_information_originate_metric: 100
nssa_default_information_originate_metric_type: 1
nssa_no_summary: true
nssa_no_redistribution: true
passive_interface_default: true
passive_interfaces:
- interface_type: GigabitEthernet
interface_id: "0/0/1"
- interface_type: Vlan
interface_id: "100"
non_passive_interfaces:
- interface_type: GigabitEthernet
interface_id: "0/0/0"
- interface_type: GigabitEthernet
interface_id: "0/0/2"
- id: 200
bfd_all_interfaces: false
default_metric: 20
auto_cost_reference_bandwidth: 1000
networks:
- ip: 172.16.0.0
wildcard: 0.0.255.255
area: "0"
router_id: 172.16.1.1
passive_interface_default: false
- id: 300
log_adjacency_changes: true
nsf_cisco: true
nsf_cisco_enforce_global: true
max_metric_router_lsa: true
max_metric_router_lsa_summary_lsa_metric: 16711680
max_metric_router_lsa_external_lsa_metric: 16711680
max_metric_router_lsa_include_stub: true
max_metric_router_lsa_on_startup_time: 60
fast_reroute_per_prefix_enable_prefix_priority: high
redistribute:
connected: true
connected_metric: 200
connected_metric_type: 2
static: true
static_metric_type: 1
static_route_map: RM_STATIC
static_tag: 500
ospf:
- process_id: 200
match_internal: true
match_external_1: true
metric: 150
metric_type: 1
route_map: RM_OSPF_REDIST
distribute_list_in: "10"
distribute_list_out: "20"
interfaces:
loopbacks:
- id: 100
description: OSPF multi-area interface
ipv4:
address: 192.168.100.1
address_mask: 255.255.255.255
ospf:
process_ids:
- id: 300
areas:
- 0
multi_area_ids:
- 10
- 20

OSPF supports three interface-level authentication modes. These are mutually exclusive — only one can be set per interface.

References a key chain (configured via key_chains) for cryptographic authentication, supporting algorithm rotation and key lifetimes.

interface Loopback100
ip ospf authentication key-chain OSPF-AUTH
ip ospf 1 area 0
iosxe:
devices:
- name: Device1
configuration:
interfaces:
loopbacks:
- id: 100
ospf:
authentication_key_chain: OSPF-AUTH
process_ids:
- id: 1
areas:
- 0

Enables MD5 authentication on the interface. Requires message_digest_keys to define the key ID and password.

interface Loopback101
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 md5pass123
ip ospf 1 area 0
iosxe:
devices:
- name: Device1
configuration:
interfaces:
loopbacks:
- id: 101
ospf:
authentication_message_digest: true
message_digest_keys:
- id: 1
md5_auth_key: md5pass123
md5_auth_type: "0"
process_ids:
- id: 1
areas:
- 0

Explicitly disables authentication on a specific interface, even when area-level authentication is enabled.

interface Loopback102
ip ospf authentication null
ip ospf 1 area 0
iosxe:
devices:
- name: Device1
configuration:
interfaces:
loopbacks:
- id: 102
ospf:
authentication_null: true
process_ids:
- id: 1
areas:
- 0

OSPF (Open Shortest Path First) is a standards-based link-state interior gateway protocol that uses Dijkstra’s shortest path first algorithm to calculate optimal routes through a network topology stored in a synchronized link-state database. It provides fast convergence, load balancing across equal-cost paths, and hierarchical network design through area-based segmentation that reduces routing overhead and improves scalability in large networks. OSPF supports advanced features including route summarization, authentication, traffic engineering extensions, and integration with MPLS for comprehensive enterprise and service provider routing solutions.

Diagram
NameTypeConstraintMandatoryDefault Value
ospf_processesList[ospf_processes]No

ospf_processes (iosxe.devices.configuration.routing)

Section titled “ospf_processes (iosxe.devices.configuration.routing)”
NameTypeConstraintMandatoryDefault Value
idIntegermin: 1, max: 65535No
vrfStringNo
bfd_all_interfacesBooleantrue, falseNo
default_information_originateBooleantrue, falseNo
default_information_originate_alwaysBooleantrue, falseNo
default_metricIntegermin: 1, max: 16777214No
distanceIntegermin: 1, max: 255No
domain_tagIntegermin: 1, max: 4294967295No
mpls_ldp_autoconfigBooleantrue, falseNo
mpls_ldp_syncBooleantrue, falseNo
neighborsList[neighbors]No
networksList[networks]No
priorityIntegermin: 0, max: 127No
router_idStringNo
shutdownBooleantrue, falseNo
summary_addressesList[summary_addresses]No
areasList[areas]No
passive_interface_defaultBooleantrue, falseNo
auto_cost_reference_bandwidthIntegermin: 1, max: 4294967No
passive_interfacesList[passive_interfaces]No

neighbors (iosxe.devices.configuration.routing.ospf_processes)

Section titled “neighbors (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
ipIPYes
priorityIntegermin: 0, max: 255No
costIntegermin: 1, max: 65535No

networks (iosxe.devices.configuration.routing.ospf_processes)

Section titled “networks (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
ipIPYes
wildcardStringNo
areaAnyString or Integer[min: 0]No

summary_addresses (iosxe.devices.configuration.routing.ospf_processes)

Section titled “summary_addresses (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
ipIPYes
maskIPNo

areas (iosxe.devices.configuration.routing.ospf_processes)

Section titled “areas (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
idAnyString or Integer[min: 0]No
authentication_message_digestBooleantrue, falseNo
nssaBooleantrue, falseNo
nssa_default_information_originateBooleantrue, falseNo
nssa_default_information_originate_metricIntegermin: 0, max: 16777214No
nssa_default_information_originate_metric_typeIntegermin: 1, max: 2No
nssa_no_summaryBooleantrue, falseNo
nssa_no_redistributionBooleantrue, falseNo

passive_interfaces (iosxe.devices.configuration.routing.ospf_processes)

Section titled “passive_interfaces (iosxe.devices.configuration.routing.ospf_processes)”
NameTypeConstraintMandatoryDefault Value
interface_typeChoiceLoopback, Vlan, GigabitEthernet, TwoGigabitEthernet, FiveGigabitEthernet, TenGigabitEthernet, TwentyFiveGigabitEthernet, FortyGigabitEthernet, HundredGigabitEthernetNo
interface_idAnyString or Integer[min: 0]No

By using Dijkstra’s algorithm and area-based segmentation, OSPF provides fast convergence, scalable routing, and robust network design.

Key Components:

  • OSPF Process ID (id): Identifies the OSPF routing process.

  • Router ID (router_id): Sets the unique router ID for the process.

  • Network Statements (networks): Advertises networks into OSPF with IP, wildcard mask, and area.

  • Area Type (areas): Configures area types (normal, stub, NSSA, totally stubby).

  • Interface Cost (neighbors.cost): Sets the cost for OSPF interfaces.

  • Interface Priority (neighbors.priority): Sets the priority for OSPF interfaces.

  • Authentication (areas.authentication_message_digest): Enables OSPF authentication (simple, MD5).

  • Default Information Originate (default_information_originate): Advertises a default route into OSPF.

  • Route Summarization (summary_addresses): Configures inter-area and external route summarization.

  • Administrative Distance (distance): Sets the OSPF administrative distance.

  • Bidirectional Forwarding Detection (BFD) (bfd_all_interfaces): Enables BFD for OSPF interfaces.

  • Passive Interface (passive_interface_default, passive_interfaces): Configures passive interfaces.

  • Reference Bandwidth (auto_cost_reference_bandwidth): Sets reference bandwidth for auto-cost calculation.

  • VRF Association (vrf): Associates OSPF process with a VRF.

Key Parameters Briefly Explained:

  • id: OSPF process identifier.
  • router_id: Unique router ID.
  • networks: Network statements for OSPF.
  • areas: Area configuration and types.
  • neighbors.cost, neighbors.priority: Interface cost and priority.
  • areas.authentication_message_digest: Authentication settings.
  • default_information_originate: Default route advertisement.
  • summary_addresses: Route summarization.
  • distance: Administrative distance.
  • bfd_all_interfaces: BFD enablement.
  • passive_interface_default, passive_interfaces: Passive interface settings.
  • auto_cost_reference_bandwidth: Reference bandwidth.
  • vrf: VRF association.

You can use these OSPF parameters to design and implement a scalable and efficient routing infrastructure. Customize the process ID, router ID, network statements, area types, and interface settings to fit your network’s topology, performance requirements, and security policies. Adjusting these parameters lets you tailor OSPF’s behavior for optimal route calculation and distribution.

The following configuration describes how to set up OSPF on a Cisco IOS-XE device, including process definition, router ID, network advertisement, area configuration, default route origination, passive interfaces, and VRF association.

router ospf 100
router-id 192.168.1.1
bfd all-interfaces
default-information originate always metric 10
auto-cost reference-bandwidth 10000
network 192.168.1.0 0.0.0.255 area 0
network 10.0.0.0 0.255.255.255 area 1
passive-interface default
no passive-interface GigabitEthernet0/0
passive-interface Vlan100
area 1 authentication message-digest
area 1 nssa default-information-originate metric 100 metric-type 1 no-summary
!
router ospf 200 vrf VRF-PROD
router-id 172.16.1.1
default-metric 20
network 172.16.0.0 0.0.255.255 area 0

The following YAML code defines OSPF configuration on an IOS-XE device, including multiple OSPF processes, VRF association, BFD settings, default route origination, auto-cost reference bandwidth, neighbor configuration, networks, router ID, summary addresses, area types, and passive interface settings.

iosxe:
devices:
- name: Device1
configuration:
routing:
ospf_processes:
- id: 100
vrf: VRF-PROD
bfd_all_interfaces: true
default_information_originate: true
default_information_originate_always: true
default_metric: 10
distance: 120
domain_tag: 10
auto_cost_reference_bandwidth: 10000
neighbors:
- ip: 192.168.1.2
priority: 10
cost: 100
- ip: 192.168.2.2
priority: 5
cost: 50
networks:
- ip: 192.168.1.0
wildcard: 0.0.0.255
area: "0"
- ip: 10.0.0.0
wildcard: 0.255.255.255
area: "1"
router_id: 192.168.1.1
shutdown: false
summary_addresses:
- ip: 10.0.0.0
mask: 255.0.0.0
- ip: 172.16.0.0
mask: 255.240.0.0
areas:
- id: "1"
authentication_message_digest: true
nssa: true
nssa_default_information_originate: true
nssa_default_information_originate_metric: 100
nssa_default_information_originate_metric_type: 1
nssa_no_summary: true
nssa_no_redistribution: true
passive_interface_default: true
passive_interfaces:
- interface_type: GigabitEthernet
interface_id: "0/0/1"
- interface_type: Vlan
interface_id: "100"
- id: 200
bfd_all_interfaces: false
default_metric: 20
auto_cost_reference_bandwidth: 1000
networks:
- ip: 172.16.0.0
wildcard: 0.0.255.255
area: "0"
router_id: 172.16.1.1
passive_interface_default: false