Learn Cisco CLI - Part 11

Open Shortest Path First

These blog posts I created to help me as a reference tool, as well as a way of retaining the knowledge. If you find it useful that’s just a plus.

OSPF (Open Shortest Path First) is a link-state routing protocol that uses the Dijkstra algorithm to determine the shortest path for data packets. It supports hierarchical routing with areas, which makes it scalable for large networks. OSPF is an open standard protocol, which means it can be used across various vendor devices.

Key features of OSPF include:

  • Fast Convergence: Quickly adapts to changes in the network topology.
  • Scalability: Supports large and complex networks through the use of areas.
  • VLSM and CIDR Support: Allows for efficient use of IP address space.

Configuration Commands

Router OSPF

Enters router configuration mode for an OSPF process. The process-id is a locally significant identifier for the OSPF process.

				
					Syntax:
router ospf [process-id]
				
			

Example:

				
					Router1>enable
Router1#configure terminal
Router1(config)#router ospf 1 
				
			

Network

Defines which interfaces run OSPF and specifies the area they belong to. The network command uses wildcard masks to match IP addresses.

				
					Syntax:
network [address] [wildcard-mask] area [area-id]
				
			
  • [address]: The IP address or range that OSPF should run on.
  • [wildcard-mask]: The inverse of the subnet mask, used to match the network.
  • [area-id]: The OSPF area identifier.

Example:

				
					Router1>enable
Router1#configure terminal
Router1(config)#router ospf 1 
Router1(config-router)#network 192.168.1.0 0.0.0.255 area 0
				
			

IP Address

Assigns an IP address to an interface. This is necessary for the interface to participate in OSPF.

				
					Syntax:
ip address [ip-address] [subnet-mask]
				
			

Example:

				
					Router1>enable
Router1#configure terminal
Router1(config)#interface FastEthernet 0/1 
Router1(config-if)#ip address 192.168.1.1 255.255.255.0
				
			

No Shutdown

Enables an interface that was previously shut down, making it active and allowing it to participate in OSPF.

				
					Syntax:
no shutdown
				
			

Example:

				
					Router1>enable
Router1#configure terminal
Router1(config)#interface FastEthernet 0/1 
Router1(config-if)#ip address 192.168.1.1 255.255.255.0
Router1(config-if)#no shutdown
				
			

Verification and Troubleshooting

Show IP OSPF Interface

Displays OSPF information for interfaces, including their state, timers, and OSPF neighbors.

				
					Syntax:
show ip ospf interface
				
			

Example:

				
					Router1>enable
Router1#show ip ospf interface
				
			

Show IP OSPF Neighbor

Displays OSPF neighbor information, showing the status of OSPF neighbors and the state of OSPF adjacency.

				
					Syntax:
show ip ospf neighbor
				
			

Example:

				
					Router1>enable
Router1#show ip ospf neighbor
				
			

Show IP Route

Displays the IP routing table, including routes learned via OSPF.

				
					Syntax:
show ip route
				
			

Example:

				
					Router1>enable
Router1#show ip route 
				
			

Output Example:

				
					O     192.168.2.0/24 [110/2] via 192.168.1.2, 00:01:23, FastEthernet0/0

				
			

EVE-NG Lab

This lab will guide you through configuring the OSPF (Open Shortest Path First) routing protocol on Cisco routers. You will learn how to configure OSPF to enable dynamic routing within a network, ensuring that different routers can communicate effectively.

Device Interface IP Address Subnet Mask
Router1
Fa0/0
10.1.1.1
255.255.255.0
Router1
S0/0
172.16.10.1
255.255.255.0
Router2
Fa0/0
10.1.1.2
255.255.255.0
Router4
S0/0
172.16.10.2
255.255.255.0

Basic Settings

Configure Interfaces

Router 1

				
					Router>enable
Router#configure terminal
Router(config)#hostname Router1
Router1(config)#interface FastEthernet 0/0
Router1(config-if)#ip address 10.1.1.1 255.255.255.0 
Router1(config-if)#no shutdown
Router1(config-if)#interface Serial 0/0  
Router1(config-if)#ip address 172.16.10.1 255.255.255.0 
Router1(config-if)#clock rate 64000
Router1(config-if)#no shutdown
Router1(config-if)#interface Serial 0/1 
Router1(config-if)#ip address 172.16.11.1 255.255.255.0 
Router1(config-if)#no shutdown
Router1(config-if)#interface FastEthernet 0/1 
Router1(config-if)#ip address 10.1.2.1 255.255.255.0 
Router1(config-if)#no shutdown 
Router1(config-if)#end
				
			

Router 2

				
					Router>enable
Router#configure terminal
Router(config)#hostname Router2
Router2(config)#interface FastEthernet 0/0 
Router2(config-if)#ip address 10.1.1.2 255.255.255.0 
Router2(config-if)#no shutdown
Router2(config-if)#end 
				
			

Router 4

				
					Router>enable
Router#configure terminal
Router(config)#hostname Router4
Router4(config)#interface Serial 0/0
Router4(config-if)#ip address 172.16.10.2 255.255.255.0 
Router4(config-if)#no shutdown
Router4(config-if)#interface FastEthernet 0/0 
Router4(config-if)#ip address 192.168.1.1 255.255.255.0 
Router4(config-if)#no shutdown
Router4(config-if)#end
				
			

Router 5

				
					Router>enable
Router#configure terminal
Router(config)#hostname Router5
Router5(config)#interface Serial 0/0
Router5(config-if)#ip address 172.16.11.2 255.255.255.0 
Router5(config-if)#no shutdown
Router5(config-if)#interface FastEthernet 0/0
Router5(config-if)#ip address 192.168.2.1 255.255.255.0 
Router5(config-if)#no shutdown
Router5(config-if)#end
				
			

Router 3

				
					Router>enable
Router#configure terminal
Router(config)#hostname Router3
Router3(config)#interface FastEthernet 0/0
Router3(config-if)#ip address 10.1.2.2 255.255.255.0 
Router3(config-if)#no shutdown
Router3(config-if)#end
				
			

Configuring OSPF

Router 1

Configure OSPF

Enter OSPF Router Configuration Mode:

				
					Router1(config)#router ospf 1 
Router1(config-router)#
				
			

Define OSPF Networks

Add FastEthernet 0/0 Network:

				
					Router1(config-router)#network 10.1.1.0 0.0.0.255 area 0 

				
			

Add FastEthernet 0/1 Network:

				
					Router1(config-router)#network 10.1.2.0 0.0.0.255 area 0 

				
			

Add Serial 0/0 Network:

				
					Router1(config-router)#network 172.16.10.0 0.0.0.255 area 0 
				
			

Add Serial 0/1 Network:

				
					Router1(config-router)#network 172.16.11.0 0.0.0.255 area 0 
				
			

Explanation: The network command specifies which interfaces will participate in OSPF. The wildcard mask (0.0.0.255 for /24) and area 0 indicate the OSPF area.

Router 2

Configure OSPF

Enter OSPF Router Configuration Mode:

				
					Router2(config)#router ospf 1 
Router2(config-router)#
				
			

Define OSPF Network

Add FastEthernet 0/0 Network:

				
					Router2(config-router)#network 10.1.1.0 0.0.0.255 area 0 
Router2(config-router)#end
				
			

Router 4

Configure OSPF

Enter OSPF Router Configuration Mode:

				
					Router4(config)#router ospf 1 
Router4(config-router)#
				
			

Define OSPF Network

Add Serial 0/0 Network:

				
					Router4(config-router)#network 172.16.10.0 0.0.0.255 area 0 
				
			

Add FastEthernet 0/0 Network:

				
					Router4(config-router)#network 192.168.1.0 0.0.0.255 area 0 
				
			

Router 5

Configure OSPF

Enter OSPF Router Configuration Mode:

				
					Router5(config)#router ospf 1 
Router5(config-router)#
				
			

Define OSPF Networks:

Add Serial 0/0 Network:

				
					Router5(config-router)#network 172.16.11.0 0.0.0.255 area 0
				
			

Add FastEthernet 0/0 Network:

				
					Router5(config-router)#network 192.168.2.0 0.0.0.255 area 0
				
			

Router 3

Configure OSPF

Enter OSPF Router Configuration Mode:

				
					Router3(config)#router ospf 1 
Router3(config-router)#
				
			

Define OSPF Network:

Enter OSPF Router Configuration Mode:

				
					Router3(config-router)#network 10.1.2.0 0.0.0.255 area 0 
				
			

Verifying OSPF Configuration

Verify OSPF Neighbors

Show OSPF Neighbors

Show OSPF Neighbors on Router1:

				
					Router1#show ip ospf neighbor
				
			

Expected Output:

				
					sqlCopy code
Neighbor ID     Pri   State           Dead Time   Address         Interface
172.16.10.2      1    FULL/DR         00:00:32    172.16.10.2     Serial0/0
10.1.1.2         1    FULL/BDR        00:00:32    10.1.1.2        FastEthernet0/0
...


				
			

Verify OSPF Routes

Show IP Route

Show IP Route on Router1:

				
					Router1#show ip route
				
			

Expected Output:

				
					pythonCopy code
O    10.1.2.0/24 [110/2] via 172.16.10.2, 00:00:32, Serial0/0
...


				
			

Verify OSPF Process

Show IP Protocols

Show OSPF Process on Router1:

				
					Router1#show ip protocols
				
			

Expected Output:

				
					pythonCopy code
Routing Protocol is "ospf 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 10.1.1.1
...
				
			

Leave a Comment