How to configure OSPF on router | Configuration Methods Cisco

OSPF Configuration methods: 

You can enable/configure OSPF on a router by following two methods.
·         Enable OSPF using network command in router process mode
·         Enable OSPF using IP OSPF command in interface mode

OSPF Configuration  using network command in router process mode
1.       First enable the OSPF process using “router ospf<process-id>”
2.    Then using network command enable OSPF process & area for an interface.

Network command syntax:

router ospf   <process--_id>
network <IP A.B.C.D> <wildcard bits> area <area_--id>
router ospf  1
network area 0

The OSPF process-id can be any number that you want, it’s not the same as AS in EIGRP.  It does not have to be same on all the routers.  But it is recommended that you should use the same process-id on all routers because when a router running multiple OSPF processes will create multiple database instances on same router that add extra overload on a router. Also when you are using different OSPF process-ids it is difficult to remember them. So Cisco recommends you to use single OSPF process-id.    
The network command is a way of assigning an interface to a certain area. The ospf configuration relay heavily on the wildcard mask. The mask contains wild card bits where 0 is a match and 1 is a "do not care" bit, e.g. indicates a match in the first three bytes of the network number that is 168.168.1.x. by above command router enable the OSPF on interface that are matching with 192.168.1.x in area 0. The area-id is the area number we want the interface to be in. The area-id can be an integer between 0 and 4294967295. Area 0 represents backbone area.

OSPF configuration Example:

In figure router are running in OSPF area 0 connected through serial interfaces. 


interface serial 1/1

ip address

interface serial 1/0
ip address

To enable OSPF using network command you need the following configuration.
Router0(config)#router ospf  1
Router0(config-rtr)#network area 0

Router1(config)#router ospf  1
Router1(config-rtr)#network area 0

Enable OSPF using IP OSPF command in interface
You can also enable the OSPF by using “ip ospf <process-id> area <area-id>” command in interface mode. This feature is support by new IOS, router having old IOS may not support this.
1.       Enter into interface mode using “interface <interface name>”
2.       Use command “ip ospf <number> area <area-id>” to run the interface in specific area
This is a handy command you can easily enable OSPF without using any wildcard mask which is a bit confusing way. For above example you can enable OSPF in interface mode by following command.

Router0(config)#interface s 1/1
Router0(config-if)#ip ospf 1 area 0

Router1(config)# interface s 1/0
Router1(config-rtr)# ip ospf 1 area 0

OSPF configuration Examples: