top of page
  • Writer's pictureMc Cube

Dive into basic OSPF Configuration (Single Area)

Updated: Mar 25, 2022




Introduction


Open Shortest Path First is a dynamic routing protocol. This is an open-source protocol meaning it should be compatible with any form of device that has routing function. OSPF is a Link State protocol, as it monitors the state of links on the network and updates it topology depending on available paths.

It was once described to me that; a distance vector protocol (EIGRP) is similar to following road signs to a destination. The path to the destination is picked while on route. Sign says "left" you go left. This works but you may find yourself on a road with roadworks, or an accident that you had no idea about, and be forced to follow "diversion" signs. Link state is more like having a live GPS system. Paths with roadworks are automatically re-routed around for and a more efficient route is discovered.


At CCNA level there are a couple other things to note about OSPF.

  • It has an Administrative Distance of 110

  • The OSPF Metric is based on a cost. Different link types have different costs associated with them. This is calculated with Dijkstra algorithm.

  • When costs were originally developed the fastest links were Fast Ethernet (100 Mbps)

    • The default values don't work well to calculate the cost of faster links (Gig and 10Gig)

    • This is because the Cost must be an integer (whole number) When calculating a faster link, the answer is a float (decimal number) and is rounded up to the nearest whole number. This means 10Gig links have the same cost as a 1Gig link.

      • E.g.

        • Cost = Reference bandwidth (100) / interface bandwidth (varies)

        • 10mg Ethernet cost = 100 / 10 = 10

        • 100mg FastEthernet cost= 100 / 100 = 1

        • 1000mg GigEthernet cost = 100 / 1000 = 0.1 = 1

        • 10000mg 10GigEthernet cost = 100 / 10000 = 0.01 = 1

**Note - Because of this, it is good practice to change the Reference bandwidth that is used. **

  • E.g.

    • Cost = Modified Reference bandwidth (10000) / interface bandwidth (varies)

    • 10mg Ethernet cost = 10000 / 10 = 1000

    • 100mg FastEthernet cost= 10000 / 100 = 100

    • 1000mg GigEthernet cost = 10000 / 1000 = 10

    • 10000mg 10GigEthernet cost = 10000 / 10000 = 1

  • OSPF uses Multicast addresses

    • 224.0.0.5 Used by all OSPF Routers

    • 224.0.0.6 Only to Designated and Backup Designated Routers (DR/BDR)

  • In a broadcast network a DR and BDR are elected to help control adjacencies between routers.

  • Can be configured as Single or Multi "Area".

If you are studying for your CCNA then this lab is ideal to help you understand several components of this configuration on a Cisco IOS device.


Instructions


In this lab (Download lab pack here) we will configure routers R1, R2, and R3 to work using Open Shortest Path First. Each router will advertise their locally connected networks to the other routers. To do all of this we will conduct the following steps...

1. On each of the routers, the interfaces will need to be configured with the IP addressing information provide in the IP table

2. Complete OSPF configuration with Process id - 999 and Area - 0 on all routers .

3. Configure all LAN interfaces as Passive

4. Redistribute a default route from R2 to the router R1 and R2.


In the initial network, only hostnames and logging synchronous enabled on the console line. (Logging synchronous is an extremely useful tool to improve your experience on the CLI especially when configuring a protocol that sends lots of messages to the console).


Topology







IP Table

Device

Interface

Address

R1

G0/0/0

10.1.2.1/24

R1

G0/0/1

10.1.3.1/24

R1

Loopback 1

192.168.1.1/24

R1

Loopback 2

192.168.2.1/24

R2

G0/0/0

10.1.2.2/24

R2

G0/0/1

10.2.3.2/24

R2

Loopback 1

208.113.96.2/28

R2

Loopback 10

10.10.10.2/24

R3

G0/0/0

10.2.3.3/24

R3

G0/0/1

10.1.3.3/24

R3

Loopback 3

192.168.3.3/24

R3

Loopback 4

192.168.4.3/24

**Note - Packet Tracer will use G0/0/0 and G0/0/1 interfaces Cisco Modelling Labs (CML) will use G0/0 and G0/1 interfaces**


Activity


Part 1 - Configure R1, R2 and R3 interfaces

1. The config below demonstrates how to initially configure interfaces on R1. You should be able to configure R2 and R3 similarly with the information in the IP Table

You may notice that I "No Shut" my loopback interfaces. This is not required as the process of creating them brings them up. This is simply a force of habit on my part.

R1> enable
R1# conf t
R1(config)# interface GigabitEthernet 0/0/0
R1(config-if)# description LINK TO R2
R1(config-if)# ip address 10.1.2.1 255.255.255.0
R1(config-if)# no shut
R1(config-if)# exit
R1(config)#
R1(config)# int g0/0/1
R1(config-if)# desc LINK TO R3
R1(config-if)# ip add 10.1.3.1 255.255.255.0
R1(config-if)# no shut
R1(config-if)# exit
R1(config)#
R1(config)# int lo1
R1(config-if)# desc LINK TO LAN1
R1(config-if)# ip add 192.168.1.1 255.255.255.0
R1(config-if)# no shut
R1(config-if)# exit
R1(config)#
R1(config)# int lo2
R1(config-if)# desc LINK TO LAN2
R1(config-if)# ip add 192.168.2.1 255.255.255.0
R1(config-if)# no shut
R1(config-if)# exit
R1(config)#

2. Repeat this process on R2 and R3 changing address information and interface details as required.


Part 2 – Configure OSPF on R1, R2, and R3

1. Firstly go into the OSPF router configuration. At this stage you need to set a Process id (PID), unlike EIGRP this number does not need to match across all routers in the OSPF domain, the PID is only locally significant. Later we will configure the Area number, this will need to match across the routers. At this point you can also configure the OSPF router ID and the new reference bandwidth.


R1

R1(config)# router ospf 999
R1(config-router)# router-id 100.100.100.1
R1(config-router)# auto-cost reference-bandwidth 1000000

R2

R2(config)# router ospf 999
R2(config-router)# router-id 100.100.100.2
R2(config-router)# auto-cost reference-bandwidth 1000000

R3

R3(config)# router ospf 999
R3(config-router)# router-id 100.100.100.3
R3(config-router)# auto-cost reference-bandwidth 1000000

2. At this stage you can start configuring the networks to be advertised. It is most likely that you will want to see what networks each specific router can advertise, the "show ip route connected" command is a great help here.

To save you the hassle of ending or exiting all the way back to privilege Exec mode. Use the "do" command.

R1(config-router)# do show ip route connected
 C 10.1.2.0/24  is directly connected, GigabitEthernet0/0/0
 C 10.1.3.0/24  is directly connected, GigabitEthernet0/0/1
 C 192.168.1.0/24  is directly connected, Loopback1
 C 192.168.2.0/24  is directly connected, Loopback2

When it comes to adding the network statements you can do a few things. Either

  • Add the specific network

R1(config-router)# network 10.1.2.0 0.0.0.255 area 0
R1(config-router)# network 10.1.3.0 0.0.0.255 area 0
R1(config-router)# network 192.168.1.0 0.0.0.255 area 0
R1(config-router)# network 192.168.2.0 0.0.0.255 area 0
R1(config-router)#
  • Assign individual interfaces in to the OSPF process.

    • This method permits great control over which interfaces are taking part on OSPF, but a disadvantage is that it is not contained within the OSPF process configuration, this means if you are troubleshooting you have to be aware of not only looking at the OSPF process but the interfaces also. In this lab we do not want to advertise Loopback 1 (simulated internet) interface we can miss it out.


R2(config-router)# exit
R2(config)# int g0/0/0
R2(config-if)# ip ospf 999 area 0
R2(config-if)#

00:21:18: %OSPF-5-ADJCHG: Process 999, Nbr 100.100.100.1 on GigabitEthernet0/0/0 from LOADING to FULL, Loading Done

R2(config-if)# exit
R2(config)# int g0/0/1
R2(config-if)# ip ospf 999 area 0
R2(config-if)# exit
R2(config)# int lo10
R2(config-if)# ip ospf 999 area 0
R2(config-if)# exit
R2(config)#
  • Although not used in this Lab, you can add a summary of addresses (In this instance all networks beginning with 10.x.x.x will be added) As mentioned earlier, we do not want to advertise the ISP network on R2. As this is the case this actually works well on this router.

    • One up/downside of this method is that any new networks added to this router that are fall inside the 10.0.0.0/8 range will automatically be included into the OSPF process and area. If the future intent is for this to happen then excellent. If this is not the intention then you will inevitably have to undo this method, in favour of the first two options.

R2(config-router)# do show ip route conn
 C   10.1.2.0/24  is directly connected, GigabitEthernet0/0/0
 C   10.2.3.0/24  is directly connected, GigabitEthernet0/0/1
 C   10.10.10.0/24  is directly connected, Loopback10
 C   208.113.96.0/28  is directly connected, Loopback1
R2(config-router)# network 10.0.0.0 0.255.255.255 area 0

00:20:04: %OSPF-5-ADJCHG: Process 999, Nbr 100.100.100.1 on GigabitEthernet0/0/0 from LOADING to FULL, Loading Done

R2(config-router)#
  • Use a full summary statement. This can be useful but should be used with caution. As Above any new network or interface you add to this router will automatically be added in to OSPF. In live environments this may not be desired, for the same reasons mentioned above. In this instance, on R3 it will work fine.


R3(config-router)#
R3(config-router)# network 0.0.0.0 255.255.255.255 area 0
R3(config-router)#

00:30:27: %OSPF-5-ADJCHG: Process 999, Nbr 100.100.100.1 on GigabitEthernet0/0/1 from LOADING to FULL, Loading Done

00:30:31: %OSPF-5-ADJCHG: Process 999, Nbr 100.100.100.2 on GigabitEthernet0/0/0 from LOADING to FULL, Loading Done

R3(config-router)# 

At this point we should have a fully converged network. We should take the time to confirm this.


R1(config-router)# end
R1# show ip ospf neighbor 

Neighbor ID    Pri State      Dead Time  Address    Interface
100.100.100.2    1 FULL/BDR   00:00:38   10.1.2.2   GigabitEthernet0/0/0
100.100.100.3    1 FULL/BDR   00:00:40   10.1.3.3   GigabitEthernet0/0/1
R1#
R2# show ip ospf neighbor 

Neighbor ID    Pri State      Dead Time   Address    Interface
100.100.100.1    1 FULL/BDR   00:00:35    10.1.2.1   GigabitEthernet0/0/0
100.100.100.3    1 FULL/DR    00:00:35    10.2.3.3   GigabitEthernet0/0/1
R2#
R3# sh ip os nei

Neighbor ID    Pri State      Dead Time   Address    Interface
100.100.100.2    1 FULL/BDR   00:00:30    10.2.3.2   GigabitEthernet0/0/0
100.100.100.1    1 FULL/BDR   00:00:39    10.1.3.1   GigabitEthernet0/0/1
R3#

Excellent!


Part 3 – Configure Passive interfaces

1. Like EIGRP, OSPF also sends out regular messages and this both the beauty in how dynamic protocols work, but also has disadvantages. As we have covered the disadvantages to this in the EIGRP blog we will quickly summarise.

  • LAN Traffic

    • Additional bandwidth utilization

    • Additional Processing of packets destined to be dropped

  • Security

    • Information about the network being intentionally distributed

    • Could be taken advantage of by hackers.

The solution to this is simple an elegant, simply stop these messages being sent out of interfaces that do not face other internal Routers.


R1# conf t
R1(config)# router ospf 999
R1(config-router)# passive-interface loopback 1
R1(config-router)# passive-interface loopback 2
R1(config-router)#
R2(config)# router ospf 999
R2(config-router)# passive-interface lo10
R2(config-router)# passive-interface lo1
R2(config-router)#
R3(config)# router ospf 999
R3(config-router)# pass lo3
R3(config-router)# pass lo4

* The above demonstrates shorter versions of the same command


Part 4 – Redistribute a default route

1. Finally, and again similar to EIGRP we can used OSPF to populate a default route to all routers in our OSPF domain. In this case a route to the simulated internet on R2.

Let's configure the default route first on R2

R2(config-router)# exit
R2(config)# ip route 0.0.0.0 0.0.0.0 lo1
%Default route without gateway, if not a point-to-point interface, may impact performance

Now let's redistribute.

R2(config)#
R2(config)# router ospf 999
R2(config-router)# default-information originate 
R2(config-router)#


Other Verifications


If you haven't already there are a few useful show commands that are helpful when configuring OSPF.

Overall OSPF configuration

Viewing your running configuration is always an easy way to reconfirm the commands you have entered. Let's use a pipe and view the OSPF section of the config with show running-config | section ospf

R1# show running-config | section ospf
router ospf 999
 router-id 100.100.100.1
 log-adjacency-changes
 passive-interface Loopback1
 passive-interface Loopback2
 auto-cost reference-bandwidth 1000000
 network 10.1.2.0 0.0.0.255 area 0
 network 10.1.3.0 0.0.0.255 area 0
 network 192.168.1.0 0.0.0.255 area 0
 network 192.168.2.0 0.0.0.255 area 0
R1#

Although viewing the running config is one of the best tools in troubleshooting (as a lot of issues are misconfiguration based at this level). Cisco like to make sure you know a few other outputs too.


View OSPF Neighbors

If you have been doing this correctly you have hopefully already seen important messages about Adjacency changes relating to the OSPF process (back here). But checking these neighbor adjacencies is equally important. If you are configuring dynamic routing, you should know which routers should be neighbors. So, if they do not appear on this list. Then something is probably wrong with your configuration (somewhere).

R1# show ip ospf neighbor 
Neighbor ID    Pri State       Dead Time   Address    Interface
100.100.100.2    1 FULL/DR     00:00:39    10.1.2.2   GigabitEthernet0/0/0
100.100.100.3    1 FULL/DR     00:00:31    10.1.3.3   GigabitEthernet0/0/1
R1#

View OSPF configuration details

The output from the show ip protocols command can be a little intimidating at first. But goes into good detail about the overall configuration of OSPF. Router ID, number of Areas, Networks advertised and passive interfaces.


R1# show ip protocol
Routing Protocol is "ospf 999"
  Outgoing update filter list for all interfaces is not set 
  Incoming update filter list for all interfaces is not set 
  Router ID 100.100.100.1
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:
    10.1.2.0 0.0.0.255 area 0
    10.1.3.0 0.0.0.255 area 0
    192.168.1.0 0.0.0.255 area 0
    192.168.2.0 0.0.0.255 area 0
  Passive Interface(s): 
    Loopback1
    Loopback2
  Routing Information Sources:  
    Gateway         Distance      Last Update 
    100.100.100.1        110      00:28:38
    100.100.100.2        110      00:07:37
    100.100.100.3        110      00:28:42
  Distance: (default is 110)


R1#

View the Routing Table

This is the reason we are here anyway. We are trying to manipulate routing tables across multiple routers. show ip route and some of its variations come in very handy.

View the full routing table


R1# show ip route
Codes: 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, E - EGP
       i - IS-IS, 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


Gateway of last resort is 10.1.2.2 to network 0.0.0.0


 10.0.0.0/8 is variably subnetted, 6 subnets, 2 masks
C   10.1.2.0/24 is directly connected, GigabitEthernet0/0/0
L   10.1.2.1/32 is directly connected, GigabitEthernet0/0/0
C   10.1.3.0/24 is directly connected, GigabitEthernet0/0/1
L   10.1.3.1/32 is directly connected, GigabitEthernet0/0/1
O   10.2.3.0/24 [110/2000] via 10.1.2.2, 10:36:57, GigabitEthernet0/0/0
                [110/2000] via 10.1.3.3, 10:36:57, GigabitEthernet0/0/1
O   10.10.10.2/32 [110/1125] via 10.1.2.2, 10:36:57, GigabitEthernet0/0/0
 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C   192.168.1.0/24 is directly connected, Loopback1
L   192.168.1.1/32 is directly connected, Loopback1
 192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C   192.168.2.0/24 is directly connected, Loopback2
L   192.168.2.1/32 is directly connected, Loopback2
 192.168.3.0/32 is subnetted, 1 subnets
O   192.168.3.3/32 [110/1125] via 10.1.3.3, 10:36:57, GigabitEthernet0/0/1
    192.168.4.0/32 is subnetted, 1 subnets
O   192.168.4.3/32 [110/1125] via 10.1.3.3, 10:36:57, GigabitEthernet0/0/1
O*E2 0.0.0.0/0 [110/1] via 10.1.2.2, 00:09:56, GigabitEthernet0/0/0
R1#

View only OSPF routes in the routing table


R1# show ip route ospf
 10.0.0.0/8 is variably subnetted, 6 subnets, 2 masks
O   10.2.3.0 [110/2000] via 10.1.2.2, 10:39:40, GigabitEthernet0/0/0
             [110/2000] via 10.1.3.3, 10:39:40, GigabitEthernet0/0/1
O   10.10.10.2 [110/1125] via 10.1.2.2, 10:39:40, GigabitEthernet0/0/0
 192.168.3.0/32 is subnetted, 1 subnets
O   192.168.3.3 [110/1125] via 10.1.3.3, 10:39:40, GigabitEthernet0/0/1
 192.168.4.0/32 is subnetted, 1 subnets
O   192.168.4.3 [110/1125] via 10.1.3.3, 10:39:40, GigabitEthernet0/0/1
O*E2 0.0.0.0/0 [110/1] via 10.1.2.2, 00:12:39, GigabitEthernet0/0/0
R1#

View the OSPF Interface information

This one is vital, because not only does it give great information about who is a designated router or Backup DR, but also the details of the network type (e.g. Broadcast or Point to Point), cost, Hello and dead timers, countdown to next hello due on each interface.

R1# show ip ospf interface 
GigabitEthernet0/0/0 is up, line protocol is up
  Internet address is 10.1.2.1/24, Area 0
  Process ID 999, Router ID 100.100.100.1, Network Type BROADCAST, Cost: 1000
  Transmit Delay is 1 sec, State BDR, Priority 1
  Designated Router (ID) 100.100.100.2, Interface address 10.1.2.2
  Backup Designated Router (ID) 100.100.100.1, Interface address 10.1.2.1
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:07
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 100.100.100.2  (Designated Router)
  Suppress hello for 0 neighbor(s)
GigabitEthernet0/0/1 is up, line protocol is up
  Internet address is 10.1.3.1/24, Area 0
  Process ID 999, Router ID 100.100.100.1, Network Type BROADCAST, Cost: 1000
  Transmit Delay is 1 sec, State BDR, Priority 1
  Designated Router (ID) 100.100.100.3, Interface address 10.1.3.3
  Backup Designated Router (ID) 100.100.100.1, Interface address 10.1.3.1
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:07
  Index 2/2, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 100.100.100.3  (Designated Router)
  Suppress hello for 0 neighbor(s)
Loopback1 is up, line protocol is up
  Internet address is 192.168.1.1/24, Area 0
  Process ID 999, Router ID 100.100.100.1, Network Type LOOPBACK, Cost: 125
  Loopback interface is treated as a stub Host
Loopback2 is up, line protocol is up
  Internet address is 192.168.2.1/24, Area 0
  Process ID 999, Router ID 100.100.100.1, Network Type LOOPBACK, Cost: 125
  Loopback interface is treated as a stub Host
R1#   


Recent Posts

See All

Comments


bottom of page