OSPF

 

OSPF over Broadcast Link

 

Introduction

Open Shortest Path First (OSPF) is a dynamic routing protocol for use in Internet Protocol (IP) networks. Specifically, it is a link-state routing protocol and falls into the group of interior gateway protocols, operating within a single autonomous system (AS). This sample configuration shows how OSPF can be configured over a broadcast link like ethernet etc.

 

Network Diagram

 

 

Configuration

 

Router A

Okapi(config)# interface FastEthernet 0
Okapi(config-if-eth)# ip address 10.20.51.5 255.255.255.0
Okapi(config)# interface FastEthernet 1
Okapi(config-if-eth)# ip address 192.168.81.5 255.255.255.0
Okapi(config)# router ospf
Okapi(config-router)# network 10.20.51.0/24 area 1

Router B

Okapi(config)# interface FastEthernet 0
Okapi(config-if-eth)# ip address 10.20.51.7 255.255.255.0
Okapi(config)# interface FastEthernet 1
Okapi(config-if-eth)# ip address 172.168.54.12 255.255.255.0
Okapi(config)# router ospf
Okapi(config-router)# network 10.20.51.0/24 area 1

 

 

Over Point-to-Point Link

 

Introduction

This sample configuration shows how OSPF can be configured over a point-to-point link.

 

Network Diagram

 

Configuration

 

Router A

Okapi(config)# interface Serial 0
Okapi(config-if-eth)# ip address 10.20.51.5 255.255.255.0
Okapi(config)# interface FastEthernet 0
Okapi(config-if-eth)# ip address 192.168.81.5 255.255.255.0
Okapi(config)# router ospf
Okapi(config-router)# network 10.20.51.0/24 area 1

Router B

Okapi(config)# interface Serial 0
Okapi(config-if-eth)# ip address 10.20.51.7 255.255.255.0
Okapi(config)# interface FastEthernet 0
Okapi(config-if-eth)# ip address 172.168.54.12 255.255.255.0
Okapi(config)# router ospf
Okapi(config-router)# network 10.20.51.0/24 area 1



Area Border Router(ABR)

 

Introduction

 

An ABR is a router that connects one or more OSPF areas. It is considered a member of all areas it is connected to. An ABR keeps multiple copies of the link-state database in memory, one for each area to which that router is connected.

Below is a configuration for an ABR. Network statements describe which interfaces we should include in ospf LSA(Link-state advertisement), and to which areas they correspond.

 

Network Diagram

Configuration

 

Okapi(config)# interface Fastethernet 0
Okapi(config-if-tunnel)# ip address 192.168.54.2/30

Okapi(config)# interface Fastethernet 1
Okapi(config-if-eth)# ip address 192.168.27.1/24

Okapi(config)# router ospf
Okapi(config-router)# ospf router-id 192.168.27.1
Okapi(config-router)# network 192.168.54.0/30 area 1.1.1.1
Okapi(config-router)# network 192.168.27.0/24 area 2.2.2.2

 

 

Advertise default Route into an Area

 

Introduction

This sample configuration shows how OSPF can be configured to advertise default route into an area.

 

Network Diagram

 

Configuration

Router A 

Okapi(config)# interface Serial 0
Okapi(config-if-eth)# ip address 192.168.54.2 255.255.255.0
Okapi(config)# interface Serial 1
Okapi(config-if-eth)# ip address 192.168.27.1 255.255.255.0

Okapi(config)# router ospf
Okapi(config-router)# network 192.168.54.0/24 area 0.0.0.0
Okapi(config-router)# network 192.168.21.0/24 area 1.1.1.1
Okapi(config-router)# default-information originate always
 
 

Simple OSPF route summarization

 

This shows how to summarize routes in OSPF, area... range is the key here. It means all networks inside 2.3.0.0/16 will be suppressed and announced to other areas as 2.3.0.0/16 instead of whole bunch of smaller networks (e.g. 2.3.2.0/24).

Okapi(config)# router ospf
Okapi(config-router)# ospf router-id 1.2.3.4
Okapi(config-router)# network 1.2.3.0/24 area 0.0.0.0
Okapi(config-router)# network 2.3.4.0/24 area 0.0.0.1
Okapi(config-router)# area 0.0.0.1 range 2.3.0.0/16

 

 

Enable OSPF Authentication

 

Network Diagram

Plain Authentication:

 

Configuration

 

Router A

Okapi(config)# interface Serial 0
Okapi(config-if-eth)# ip address 10.20.51.5 255.255.255.0
Okapi(config-if-eth)# ip ospf authentication-key ABCDEFGHIJK

Okapi(config)# router ospf
Okapi(config-router)# network 10.20.51.0/24 area 1
Okapi(config-router)# area 1 authentication

Router B

Okapi(config)# interface Serial 0
Okapi(config-if-eth)# ip address 10.20.51.7 255.255.255.0
Okapi(config-if-eth)# ip ospf authentication-key ABCDEFGHIJK

Okapi(config)# router ospf
Okapi(config-router)# network 10.20.51.0/24 area 1
Okapi(config-router)# area 1 authentication

 

 

MD5 Authentication

 

Configuration

 

Router A

Okapi(config)# interface Serial 0
Okapi(config-if-eth)# ip address 10.20.51.5 255.255.255.0
Okapi(config-if-eth)# ip ospf authentication message-digest
Okapi(config-if-eth)# ip ospf message-digest-key 1 md5 ABCDEFGHIJK

Okapi(config)# router ospf
Okapi(config-router)# network 10.20.51.0/24 area 1
Okapi(config-router)# area 1 authentication message-digest

Router B

Okapi(config)# interface Serial 0
Okapi(config-if-eth)# ip address 10.20.51.7 255.255.255.0
Okapi(config-if-eth)# ip ospf authentication message-digest
Okapi(config-if-eth)# ip ospf message-digest-key 1 md5 ABCDEFGHIJK

Okapi(config)# router ospf
Okapi(config-router)# network 10.20.51.0/24 area 1
Okapi(config-router)# area 1 authentication message-digest

 

 

Filtering redistributed routes using Route-map

This example shows how to redistribute routes from rip with a metric of 1 to ospf with metric of 5 and external type 1 metric.

Okapi(config)# router ospf

Okapi(config-router)# redistribute rip route-map rip-ospf

Configure route-map:

Okapi(config)# route-map rip-ospf permit
Okapi(config-route-map)# match metric 1
Okapi(config-route-map)# set metric 5
Okapi(config-route-map)# set metric-type type1

 

 

MD5 Filtering redistributed routes using distribute-list (ospf/kernel)

We want only prefixes belonging to network 20.0.0.0/8 to be redistributed from kernel to ospf. E.g. 20.1.2.0/24 and 20.3.2.0/19 will be included in redistributed routes.

Okapi(config)# router ospf 

Okapi(config-router)# redistribute kernel
Okapi(config-router)# distribute-list KERNELOUT out kernel

Configure access-list:

Okapi(config)# access-list KERNELOUT permit 20.0.0.0/8

 

 

OSPF Virtual Link

 

All the OSPF areas should be connected to the backbone area, but sometimes it is not possible. In such cases we can connect them using ospf virtual link. This sample configuration shows how to establish a ospf virtual link between 2 ospf areas.

 

Network Diagram

Configuration

 
Router A

Okapi(config)# router ospf
Okapi(config-router)# router-id 1.1.1.1
Okapi(config-router)# network 10.20.51.0/24 area 0
Okapi(config-router)# network 20.20.51.0/24 area 1
Okapi(config-router)# area 1 virtual-link 2.2.2.2

Router B

Okapi(config)# router ospf
Okapi(config-router)# router-id 2.2.2.2
Okapi(config-router)# network 30.20.51.0/24 area 1
Okapi(config-router)# network 40.20.51.0/24 area 2
Okapi(config-router)# area 1 virtual-link 1.1.1.1