How to configure basic OSPF

Image: Brandon Carroll/TechRepublicHow to configure basic OSPF

Open shortest path first, or OSPF, is a routing protocol that’s based on open standards, meaning any vendor can implement its features. For years Cisco, Juniper, and other major networking vendors have coupled OSPF into their platform. When you configure OSPF, there are a few fundamental requirements in order to exchange routing information. To begin with, OSPF uses a Hello mechanism to detect neighboring devices that run OSPF. Once detected OSPF attempts to form an adjacency. Once an adjacency is established Link-State Advertisements (LSA) are used to exchange routing information.

The Hello packet is one of the first things you should have a solid understanding of. The following image shows the format of a Hello packet:

Image: Brandon Carroll/TechRepublicHow to configure basic OSPF

This packet is used by the Hello protocol, which is responsible for establishing and maintaining neighbor relationships. The Hello protocol also ensures that communication between neighbors is bidirectional. These packets get sent out of an interface where OSPF is enabled on a periodic basis. If a router receives a packet and sees its own address listed it knows that bidirectional communication exists. Once bidirectional communication is established a Designated Router (DR) is selected if on a multiaccess network. We’re not going to cover that process in this article, however we highlight it because it’s an integral part of OSPF. After two devices neighbor up, they synchronize Link-State databases.

SEE: 20 quick tips to make Linux networking easier

To configure basic OSPF to form a neighbor adjacency on a Cisco router perform the following:How to configure basic OSPF

Identify the network interfaces that should run OSPF.

Identify the OSPF area

Issue the required commands to enable OSPFHow to configure basic OSPF

Let’s assume the following topology in which we are using OSPF area 5 and ABR5 and R5 are pre-configured for us. We need to enable OSPF on R6.

Image: Brandon Carroll/TechRepublic

Start by entering OSPF configuration mode. You’ll need to identify OSPF by a process ID. In this case, it’s 1.How to configure basic OSPF

R6>enR6#conf tEnter configuration commands, one per line. End with CNTL/Z.R6(config)#router ospf 1R6(config-router)#

Next, issue the network statement for each interface that should run OSPF. According to our network topology we will enable OSPF on interface g0/1 and g0/2. The network statement format is as follows:

network X.X.X.X W.W.W.W area AHow to configure basic OSPF

In this syntax, the X.X.X.X indicates the network address. The W.W.W.W is the wildcard mask. The A is the area ID.

R6(config-router)#network 10.0.0.80 0.0.0.3 area 5R6(config-router)#network 10.0.0.84 0.0.0.3 area 5R6(config-router)#

A simple way to identify the wildcard mask is to subtract the subnet mask in the last octet from 255. In this case 255 – 252 – 3 so our wildcard mask is going to end in .3.How to configure basic OSPF

We now need to verify that OSPF has neighbored up and synchronized databases. To do so, issue the show ip ospf neighbors command.

R6#sh ip ospf neighbor`Neighbor ID Pri State Dead Time Address Interface`192.168.0.10 1 FULL/DR 00:00:35 10.0.0.85 GigabitEthernet0/2`192.168.0.9 1 FULL/BDR 00:00:31 10.0.0.81 GigabitEthernet0/1`R6#`

As we can tell from the output, we have two neighbors. The Neighbor ID is not the IP address that we neighbored with. It’s the Router ID selected by OSPF when the protocol was enabled. This can be chosen automatically or you can manually set this value.How to configure basic OSPF

Next let’s look at our Link-State Database on R6.

R6#show ip ospf database OSPF Router with ID (10.0.0.86) (Process ID 1)Router Link States (Area 5)Link ID ADV Router Age Seq# Checksum Link count10.0.0.86 10.0.0.86 164 0x80000003 0x00EFF7 2192.168.0.9 192.168.0.9 165 0x80000006 0x00A12F 2192.168.0.10 192.168.0.10 229 0x80000006 0x00CC76 3Net Link States (Area 5)Link ID ADV Router Age Seq# Checksum10.0.0.78 192.168.0.10 1598 0x80000004 0x004B3D10.0.0.82 10.0.0.86 164 0x80000001 0x00C7E510.0.0.85 192.168.0.10 229 0x80000001 0x008313Summary Net Link States (Area 5)Link ID ADV Router Age Seq# Checksum10.0.0.4 192.168.0.9 1630 0x80000004 0x00A21710.0.0.8 192.168.0.9 1630 0x80000004 0x00704610.0.0.12 192.168.0.9 1630 0x80000004 0x00486A10.0.0.16 192.168.0.9 1630 0x80000004 0x00208E10.0.0.20 192.168.0.9 1630 0x80000004 0x00F7B210.0.0.24 192.168.0.9 1630 0x80000004 0x00C5E110.0.0.28 192.168.0.9 1630 0x80000004 0x00A7FA10.0.0.32 192.168.0.9 1630 0x80000004 0x007F1F10.0.0.36 192.168.0.9 1630 0x80000004 0x00574310.0.0.40 192.168.0.9 1630 0x80000004 0x00257210.0.0.44 192.168.0.9 1630 0x80000004 0x00078B10.0.0.48 192.168.0.9 1630 0x80000004 0x00DEAF10.0.0.52 192.168.0.9 1630 0x80000005 0x00B4D410.0.0.56 192.168.0.9 1630 0x80000004 0x008EF710.0.0.60 192.168.0.9 1630 0x80000004 0x00701110.0.0.64 192.168.0.9 1630 0x80000004 0x00344B10.0.0.68 192.168.0.9 1630 0x80000005 0x00146510.0.0.72 192.168.0.9 1630 0x80000004 0x00E393192.168.0.1 192.168.0.9 1630 0x80000004 0x0099C1192.168.0.2 192.168.0.9 1630 0x80000004 0x0099BF192.168.0.3 192.168.0.9 1630 0x80000004 0x008FC8192.168.0.4 192.168.0.9 1630 0x80000004 0x007BDC192.168.0.5 192.168.0.9 1630 0x80000004 0x0071E5192.168.0.6 192.168.0.9 1630 0x80000004 0x0071E3192.168.0.8 192.168.0.9 1630 0x80000005 0x005102192.168.0.9 192.168.0.9 1630 0x80000004 0x003F15R6#

Comparing database with R5, specifically the sequence numbers, we can see that we are synchronized:How to configure basic OSPF

R5#sh ip ospf database OSPF Router with ID (192.168.0.10) (Process ID 1)Router Link States (Area 5)Link ID ADV Router Age Seq# Checksum Link count10.0.0.86 10.0.0.86 193 0x80000003 0x00EFF7 2192.168.0.9 192.168.0.9 194 0x80000006 0x00A12F 2192.168.0.10 192.168.0.10 257 0x80000006 0x00CC76 3Net Link States (Area 5)Link ID ADV Router Age Seq# Checksum10.0.0.78 192.168.0.10 1626 0x80000004 0x004B3D10.0.0.82 10.0.0.86 193 0x80000001 0x00C7E510.0.0.85 192.168.0.10 257 0x80000001 0x008313Summary Net Link States (Area 5)Link ID ADV Router Age Seq# Checksum10.0.0.4 192.168.0.9 1658 0x80000004 0x00A21710.0.0.8 192.168.0.9 1658 0x80000004 0x00704610.0.0.12 192.168.0.9 1658 0x80000004 0x00486A10.0.0.16 192.168.0.9 1658 0x80000004 0x00208E10.0.0.20 192.168.0.9 1658 0x80000004 0x00F7B210.0.0.24 192.168.0.9 1658 0x80000004 0x00C5E110.0.0.28 192.168.0.9 1658 0x80000004 0x00A7FA10.0.0.32 192.168.0.9 1658 0x80000004 0x007F1F10.0.0.36 192.168.0.9 1658 0x80000004 0x00574310.0.0.40 192.168.0.9 1658 0x80000004 0x00257210.0.0.44 192.168.0.9 1658 0x80000004 0x00078B10.0.0.48 192.168.0.9 1658 0x80000004 0x00DEAF10.0.0.52 192.168.0.9 1658 0x80000005 0x00B4D410.0.0.56 192.168.0.9 1658 0x80000004 0x008EF710.0.0.60 192.168.0.9 1658 0x80000004 0x00701110.0.0.64 192.168.0.9 1658 0x80000004 0x00344B10.0.0.68 192.168.0.9 1658 0x80000005 0x00146510.0.0.72 192.168.0.9 1658 0x80000004 0x00E393192.168.0.1 192.168.0.9 1658 0x80000004 0x0099C1192.168.0.2 192.168.0.9 1658 0x80000004 0x0099BF192.168.0.3 192.168.0.9 1658 0x80000004 0x008FC8192.168.0.4 192.168.0.9 1658 0x80000004 0x007BDC192.168.0.5 192.168.0.9 1658 0x80000004 0x0071E5192.168.0.6 192.168.0.9 1658 0x80000004 0x0071E3192.168.0.8 192.168.0.9 1658 0x80000005 0x005102192.168.0.9 192.168.0.9 1658 0x80000004 0x003F15

Finally, let’s look to see if we have OSPF routes populating our routing table on R6:

R6#show ip routeCodes: L – local, C – connected, S – static, R – RIP, M – mobile, B – BGP D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2 E1 – OSPF external type 1, E2 – OSPF external type 2 i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2 ia – IS-IS inter area, * – candidate default, U – per-user static route o – ODR, P – periodic downloaded static route, H – NHRP, l – LISP a – application routereplicated route, % – next hop override, p – overrides from PfRGateway of last resort is not set 10.0.0.0/8 is variably subnetted, 23 subnets, 2 masksO IA 10.0.0.4/30 [110/4] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.8/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.12/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.16/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.20/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.24/30 [110/2] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.28/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.32/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.36/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.40/30 [110/2] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.44/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.48/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.52/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.56/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.60/30 [110/4] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.64/30 [110/2] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.68/30 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 10.0.0.72/30 [110/2] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O 10.0.0.76/30 [110/2] via 10.0.0.85, 00:06:30, GigabitEthernet0/2 [110/2] via 10.0.0.81, 00:05:24, GigabitEthernet0/1C 10.0.0.80/30 is directly connected, GigabitEthernet0/1L 10.0.0.82/32 is directly connected, GigabitEthernet0/1C 10.0.0.84/30 is directly connected, GigabitEthernet0/2L 10.0.0.86/32 is directly connected, GigabitEthernet0/2 192.168.0.0/32 is subnetted, 9 subnetsO IA 192.168.0.1 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 192.168.0.2 [110/4] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 192.168.0.3 [110/4] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 192.168.0.4 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 192.168.0.5 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 192.168.0.6 [110/4] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 192.168.0.8 [110/3] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O IA 192.168.0.9 [110/2] via 10.0.0.81, 00:05:24, GigabitEthernet0/1O 192.168.0.10 [110/2] via 10.0.0.85, 00:06:30, GigabitEthernet0/2R6#

As you can tell, we are receiving OSPF routes. In fact, we are receiving more routes to destinations that we don’t see in our topology. This is because we are only focusing on a small part of the topology. What we don’t see is that ABR5 is connected to several other routers forming a backbone and exchanging routes between other areas. This obviously leads to more questions about OSPF, however, as it stands we have configured basic OSPF and can now route traffic on R6.

Also see:How to speed up DNS caching on Linux machines with dnsmasqHow to integrate a Synology NAS in your VMware LabVMware NSX: The smart person’s guideHow to configure gzip compression with NGINX

Leave a Reply

Your email address will not be published. Required fields are marked *