# OSPF 1 - Basics

## Introduction

For the CCNA we need to only configure and verify a SINGLE area OSFPv2&#x20;

### Link State Routing Protocols

* Every router creates a "connectivity" map of the network
* To do this, each router advertises information about its interfaces (connected networks) to its neighbours.These advertisements are passed along to other routers, until all routers in the network develop the SAME map of the network
* THEN, each router independently uses this map to calculate the best routes to each destination
* Link state protocols are more CPU intensive as more information is shared
* BUT... they are faster  in reacting to changes in the network than DV (distance vector) protocols

### OSPF

* Open Shortest Path First  - uses the **SHORTEST PATH FIRST** algorithm invented by Dutch computer scientist Edsger Dijkstra, commonly called **Dijkstra's Algorithm**
* OSPF has **3 versions**
  * OSPF v1 (1989) - OLD and not in use any more
  * OSPF v2 (1998) - Used for IPv4 only
  * OSPF v3 (2008) - Used for IPv6 (can be used for IPv4, but usually OSPF v2 is used)
* Routers store information **ABOUT** the network in **LSA's** (link-state-advertisements) which are organised in a structure called the **LSDB (link-state-database)**
* Routers will **flood** LSA's until all routers in the OSPF **AREA** develop the same map of the network (LSDB)

#### LSA Flooding

![](/files/-MI9kl8rqaHA381c5ywS)

### OSPF - 3 Steps to Sharing LSA's and Find Best Route

1. **Become neighbours** with other routers connected  to the same segment (ie R4 became neighbours with R2 and R3
2. **Exchange LSA's** with neighbour Routers
3. **Each router independently calculates the BEST ROUTES** to each destination and inserts them into the routing table

### OSPF AREAS

OSPF uses areas to divide up the network.however small areas can be single-area without negative effects on network performance.\
For example, using a single area in a large network can produce poor performance due to the SPF algorithm taking a longer time to calculate routes, thus using up more CPU resources and also the increase in size of the LSDB takes up more memory resources.

By dividing a large OSPF network into smaller ones we can avoid the above negative effects

We define an **AREA** as:

* a set of routers  and links that share the same LSDB
* the BACKBONE area (area 0) is an area that all others MUST connect to
* Routers with all interfaces in the SAME area are called **INTERNAL ROUTERS**
* Routers with interfaces in MULTIPLE AREAS are called **Area Border Router (ABR's)**
  * ABR's maintain a **SEPARATE LSDB** for **EACH area** they are connected to. Its recommended that you connect an ABR to a **MAXIMUM of 2 areas** as connecting more that 2 can overburden the router.
* Routers connected to **Area 0** are called BACKBONE ROUTERS (This also includes ABR's)
* An **intra-area route** is a route to a destination inside the **SAME** OSPF area
* An **inter-area** **route** is a route to a destination in a **DIFFERENT** OSPF area

![](/files/-MI9ytr6f3tjakuvmOea)

* OSPF areas MUST be contiguous - ie cant have Area1, Area2 and then Area1 again - wont work, It would need to be Area 3
* All OSPF areas MUST have at least ONE ABR connected to the BACKBONE area
* OSPF interfaces in the same SUBNET must be in the same AREA

### Basic OSPF Configuration - Single Area OSPF

With the CCNA - only need to know about one area - Area 0 - the backbone Area. Here all interfaces and Routers are in Area 0 and Routers 2, 3 and 4 have already been configured. We will configure Router 1 (R1)

![](/files/-MIAypbgFPxMagB7I90v)

The configuration is very similar to EIGRP with a few differences:

![](/files/-MIAzRVZeJN7ppKpbjZl)

* The process ID - OSPF can run multiple OSPF processes at once and this process ID is **LOCALLY SIGNIFICANT** and is used to identify which instance of OSPF is running (not like EIGRP where it uses AS numbers which have to be the same across other EIGRP routers for them to achieve adjacencies)
* Network uses wildcard masks just like EIGRP and requires an AREA number to be specified. Again the network command ACTIVATES OSPF on the SPECIFIC interfaces in the specified AREA and the routers will then try to form adjacencies with neighbouring OSPF activated routers
* The **passive-interface** command - stops sending 'HELLO' messages out of those interfaces
* Added in default route to internet and then used the R1(config-router)#default-information originate to advertise the default route into OSPF
  * `R1(config-router)# passive-interface gi2/0 - stops hello messages`\
    `R1(config)# ip route 0.0.0.0 0.0.0 203.0.113.2`\
    `R1(config-router)# default-information originate  NB!! Using this command the router interface connects to the Internet so it AUTOMATICALLY BECOMES AN ASBR (autonomous system border router - an ASBR) !!!!!`\
    `R1#show ip protocols`\
    &#x20;       `**Remember Router ID is same as EIGRP. Manual configuration of the router-id takes precedence, then the highest IP address on a loopback interface and lastly if no loopback interface then the highest IP address on a PHYSICAL inetrface`\
    `R1(config-router)# router-id 1.1.1.1`\
    &#x20;       `** Router ID same as EIGRP but with OSPF - its just router-id not "ospf router-id" like in EIGRP where its configured "eigrp router-id 1.1.1.1" etc.`\
    `R1(config-router)# clear ip ospf process`\
    &#x20;       `** Unlike EIGRP we have to issue the above command for the router-id to take affect`\
    `R1(config-router)# maximum-paths 8 ---- Same as EIGRP except OSPF cannot do unequal-cost load-balancing but does support ECMP load balancing. 4 default ECMP routes configured. Changed to 8`\
    `R1(config-router)# distance 85 ----- changes OSPF defauly AD from 110 to 85 so OSPF routes are now preferred over EIGRP routes on this router..`

![](/files/-MIBfxh9nc7nvBOXaK-J)

### QUIZ - Q1

![](/files/-MIBh698XDkoOdyavb08)

### QUIZ - Q2

![](/files/-MIBhXlj-kl8CEGI0WZz)

### QUIZ - Q3

![](/files/-MIBiJMpzqPiMD8oJpNS)

### QUIZ 4

![](/files/-MIBivBVfVsfnE-NCcQJ)

### QUIZ 5

![](/files/-MIBjC5WvBn3uK86A2Rc)

### QUIZ 6

![](/files/-MIBjfBDs05muquJXI91)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cisco.microcisco.com/icnd-1/routing/ospf.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
