How to Configure OSPF in a Single Area?

Posted by betsyyu on August 2, 2012

OSPF stands for Open Shortest Path First and it represents a routing protocol belonging to the group of link-state routing protocols. OSPF routing protocol is classified among the best dynamic protocols that exist in networks today. It is also considered to be a sophisticated routing protocol that aims to maintain loop-free and accurate routing tables. Here we’ll go over the necessary commands that are needed to enable the OSPF routing protocol, define OSPF networks, configure advanced options, and more. We’ll also look at how and why OSPF is used. Let’s get started by taking a look at some Unlike distance vector protocols, link-state routing protocols, and specifically OSPF, hold the following key points:

      

Information about its neighbors (local connectivity) is sent to the entire network using multicasting The entire routing table is transmitted once every 30 minutes Link-state updates (LSAs) are transmitted when there is a change in the state of the links HELLO messages are used to maintain adjacent neighbors Is a classless routing protocol which uses VLSM and both manual and automatic summarization Uses COST as a metric which CISCO defines as the inverse of the bandwidth AREA terminology is created to provide a hierarchical structure and limit the multicast LSAs within routers of the same area — the default or otherwise core area is area 0 and all other areas connect directly to it

Based on OSPF LSAs, each router constructs a topology table which contains every connection link within the network. Then, the Dijkstra algorithm runs over the topology table to find the shortest path to every other router, and hence creates the routing table. This algorithm, which is also known as the SPF algorithm, runs on every OSPF enabled router on the network, and routers within a particular area all have the same topology tree of the specific area.

Enabling the OSPF Routing Protocol The following command is needed in order to enable OSPF routing protocol on the router:

Router(config)#router ospf process-number

The process-number is nothing more than a number local to the router. It’s only used to distinguish processes within a router and can be given an arbitrary value. This value does not have to be the same on every router within the area. However, it is always good practice to keep this number the same for better administration.

area 0 is the first one that needs to be defined. Therefore the following command is needed to make OSPF operational:  Router(config-router)#network address wildcard-mask area area-number The address can be the network address. . or the address of a specific interface. This will become clearer in the next section on Defining OSPF Networks Examples. subnet. if more than one area is to be created in a network. The network command is used to identify the interfaces on the router that are going to participate in the OSPF process. The OSPF process needs to know the networks that are going to be advertised (i. area 0 is used. Defining OSPF Networks Examples The schematic diagram below illustrates how a single command is able to cover all router interfaces and also how individual interfaces can be specified. Adjacencies will be created with these interfaces and LSAs will be received and transmitted on these interfaces. The area-number specifies the area to be associated with the specific address and consequently the interfaces to be grouped within that area.Defining OSPF Networks Enabling OSPF is not enough to activate it. Each 0 bit indicates a “must” and each 1 bit indicates an “any”. By default. the interfaces on which OSPF will run) and the area they reside in.e. The wildcard-mask consists of 4 groups of 8-bits each. Therefore the wildcard-mask parameter needs to be defined for accurately identifying the necessary interfaces.

1. These options include:     Configuring a loopback interface Specifying the router ID (RID) Manipulating the cost command Changing the routers priority Configuring a Loopback Interface The source of Link-state Advertisements in a given area is identified by the RID. subnet and the other in the 172.0 to participate in OSPF:  Router(config-router)#network 192. one in the 192.0. RouterA has 3 interfaces. . one in the This ID has the form of an IP address and can be automatically or manually defined.In the diagram above. The following command configures all interfaces to participate in OSPF area 0:  Router(config-router)#network subnet.255.255 area 0 The following command specifically forces the serial interface to participate in OSPF area 0:  Router(config-router)#network 172.1 0.0. though they are not necessary for OSPFs normal operation.255 area 0 The following command will force only interfaces addressed from 192.0 area 0 Configuring Advanced Options A few advanced options can be useful in administrating OSPF.255.

Even when a manual configuration change of the RID is performed. the router takes into consideration the costs of the links along various paths. For calculating the SPF to a given destination. The following commands show how to manually configure the RID. Any unique IP address can be defined as RID and it never changes even if the interface that the router is using for the RID goes down. The path with the lower cost is selected as the shortest path. hence the RID will never have to change. It is wise to configure a loopback interface on the router because this kind of interface is a virtual one that can never go down.Automatic selection of RID If no manual RID is specified. then the highest IP address of an active interface is chosen as the RID. To force the router to pick up a certain path. the OSPF process assigns cost values to interfaces based on the inverse of the bandwidth parameter assigned to the interface with the bandwidth command. If no loopback interface is defined. manual setting of the cost on a link along the path can be achieved using the following command:  Router(config-if)#ip ospf cost cost . then the RID is taken from the highest IP address assigned to a loopback interface. this does not take effect until the next router reload or OSPF routing restart. The following commands define and configure a loopback interface:   Router(config)#interface loopback interface-number Router(config-if)#ip address ip-address subnet-mask Manual Configuration of RID This is the preferred method of defining the RID. The clear ip ospf process command is used to activate the RID on a router that is already running OSPF:    Router(config)#router ospf process-number Router(config-router)#router-id ip-address Router#clear ip ospf process Configuring the Cost of an Interface As already mentioned.

The following command configures a priority value on an interface. SPF algorithm runs over this topology tree and computes the shortest path from every router to every other router in the area. The priority command is assigned on an interface. The range is from 0 to 255.Setting Priority for the Selection of the Designated Router In multi-access networks the router with the highest priority value is chosen as the DR which acts as the central point of LSAs exchange. This information allows each router to build a complete topological tree consisting of routers and omnidirectional links connecting them together. Default priority for an OSPF interface is 1. OSPF routing protocol is classified among the best dynamic protocols existing in networks today.   Router(config)#interface interface-number Router(config-if)#ip ospf priority priority-value Why Use OSPF? As I mentioned at the beginning. Each of these links carries a cost value. The results from SPF algorithm construct the router’s routing table. It has all the necessary features of an interior gateway routing protocol:    Scalability Adaptability to topology changes Topology awareness within its operation area OSPF uses multicasting so that each router informs all other routers in the area of its neighbors and costs. . 0 means that the interface does not involve in the DR election.