OSPF (Open Shortest Path First) - IOS

Function: 
Summary
  • A link state routing protocol, in which each router sends information on the cost metric of its network interfaces to all other routers in the network.
Detailed Description
  • OSPF gathers link state information from available routers and constructs a topology map of the network. The topology determines the routing table presented to the Internet Layer which makes routing decisions based solely on the destination IP address found in IP packets. OSPF detects changes in the topology, such as link failures, very quickly and converges on a new loop-free routing structure within seconds. It computes the shortest path tree for each route using a method based on Dijkstra’s algorith, a shortest path first algorithm.
Configuration Commands
  • Configuring OSPF
Global Configuration:  
router ospf process-id -Enables an OSPF routing process. Each router can execute multiple OSPF processes. process-id is a number that identifies the process.
no router ospf process-id -Disables the specified OSPF process.
Privileged EXEC:  
show ip ospf -Displays general information about the OSPF configuration.
show ip ospf database -Displays the link state database.
show ip ospf border-routers -Displays the Area Border Router (ABR) and Autonomous System Boundary Router (ASBR).
clear ip ospf process-id process -Resets the specified OSPF process
Router Configuration:  
network Netaddr InvNetmask area AreaID

-Associates a netowrk prefix with OSPF and associates an OSPF area to the network address. The prefix is specified with an IP address (Netaddr) and an inverse netmask (InvNetmask).
no network Netaddr InvNetmask area AreaID -Disables OSPF for the specified network area.
passive-interface Iface -Sets interface Ifaceinto passive mode. In passive mode, the router only receives and processes OSPF packets and does not transmit OSPF messages.
no passive-interface Iface -Sets interface Ifaceinto active mode. In active mode, the router receives and transmits OSPF messages.
router-id IPaddress -Assigns the IP address IPaddressas the router identifier (router-id) of the local OSPF router. The router-id is used in LSA messages to identify a router. In IOS, by default, a router selects the highest IP address as the router-id. This command can be used to set the value explicityly.
Examples
  • Example commands for configuring a Cisco router to run OSPF:

Router1> enable

Password: <enable secret>

Router1# configure terminal

Router1(config)# no ip routing

Router1(config)# ip routing

Router1(config)# no router rip

Router1(config)# router ospf 1

Router1(config-router)# network 10.0.0.0 0.255.255.255 area 1

Router1(config-router)# interface Fa0/0

Router1(config-if)# ip address 10.0.3.3 255.255.255.0

Router1(config-if)# interface Fa0/1

Router1(config-if)# ip address 10.0.2.3 255.255.255.0

Router1(config-if)# end

Router1# clear ip route *

The above commands enable OSPF for Area 1 and network 10.0.0.0/8, and configure the IP addresses of the routers. Since no router-id is specified, the highest IP address of Router1, 10.0.3.3, is used as the router-id. The router-id can be verified by issuing the command show ip ospf.
Links Cisco OSPF documentation

PacketLife Cheat Sheets: OSPF