Configure the OSPF and Verify Two Routers Connection in Cisco Packet Tracer
Here we will take an example by using the CISCO packet tracer to configure ospf in the network which contains two routers two switchs and two pcs as shown in below figure 1. now open the cisco packet tracer and select the following devices as shown below:
S.no |
Device |
Qty |
---|---|---|
1 |
PC | 2 |
2 |
Switch | 2 |
3 |
Router | 2 |
- Use the automatic connecting wire to connect the devices with each other and the topology as shown in figure 1.
Now we have to assign the ip address as shown below table to each pc and router this is done by the following steps:
S.NO |
Device |
Interface |
IPv4 Address |
Subnet-Mask |
Default-Gateway |
---|---|---|---|---|---|
01 | PC1 | 192.168.1.2 | 255.255.255.0 | 192.168.1.3 | |
02 | PC2 | 192.168.2.2 | 255.255.255.0 | 192.168.2.3 | |
03 | Router 0 | GigabitEthernet0/0 | 192.168.1.3 | 255.255.255.0 | |
GigabitEthernet0/1 | 192.168.3.2 | 255.255.255 | |||
04 | Router 1 | GigabitEthernet0/0 | 192.168.2.3 | 255.255.255.0 | |
GigabitEthernet0/1 | 192.168.3.3 | 255.255.255.0 |
Step1: select pc1 then go to Desktop then select ip configration and assign the ip address to pc1 as shown below:
Step2: select PC2 then go to Desktop then select ip configration and assing the ip address to pc1 as shown below:
Step 3:Here we have two methods to assing ip address to router0:
- Graphical method: select the router0 R0 go to config then select GigabitEthernet0/0 then assign ip address 192.168.1.3 similarly go to GigabitEthernet0/1 to assign the ip address 192.168.1.3 as shown in figure below:
Command line: in this method select the router R0 then go to CLI and enter the following commands as shown below to set the ip address of GigabitEthernet0/0 and GigabitEthernet0/1:
GigabitEthernet0/0
Router>enable
Router#configure terminal
Router(config)#interface GigabitEthernet0/0
Router(config-if)#ip address 192.168.1.3 255.255.255.0
GigabitEthernet0/1
Router(config)#interface GigabitEthernet0/0
Router(config-if)#ip address 192.168.1.3 255.255.255.0
Step4: select the router R1 and similarly as shown in step2 assign the ip address as shown in tabble II to GigabitEthernet0/1 and GigabitEthernet0/0
After these steps will done now we have to follow these steps to configure ospf in two routers R0 and R1 :
Step 1:Select the router R0 then go to CLI and enter the below commands:
Router> enable
Router# config t
Router(config)#router ospf 1
Router(config-router)#network 192.168.1.0 0.0.0.255 area 0
Router(config-router)#network 192.168.3.0 0.0.0.255 area 0
Step 2:Select the router R1 then go to CLI and enter the below commands:
Router> enable
Router# config t
Router(config)#router ospf 2
Router(config-router)#network 192.168.2.0 0.0.0.255 area 0
Router(config-router)#network 192.168.3.0 0.0.0.255 area 0
After configuring the ospf now we will verify ospf is working or not to this we will ping from pc1 to pc2. To do this select pc1 and go to command prompt and enter the following command:
Ping 192.168.2.3
as shown in figure 5 the packets are received successfully and now ospf is working successfully.
Now we will ping from pc2 to pc1 by entering the following command:
Ping 192.168.1.3
as shown in figure 6 the packets are successfully received which means OSPF is working successfully
What is OSPF Interface Cost?
OSPF (Open Shortest Path First) interface cost is a metric used by the OSPF routing protocol to determine the best path to a destination. It represents the cost of sending data across a specific link, and it is calculated based on the bandwidth of the link. The formula for calculating the cost of interface in Cisco router is, as follows.
interface Cost = Reference Bandwidth(Mbps) / Interface Bandwidth(Mbps)
By default the value of reference bandwidth is 100Mbps. OSPF interface cost plays a crucial role in determining the path selection process in OSPF. When OSPF receives multiple paths to a destination, it chooses the path with the lowest cumulative interface cost. This means that the path with the lowest total cost (sum of interface costs) is selected as the best path to the destination.
Network administrators can manipulate the path selection process by adjusting the cost of specific interfaces. For example, increasing the cost of an interface will make OSPF less likely to use that path, and decreasing the cost will make OSPF more likely to use that path.
In summary, OSPF interface cost is a critical metric used by OSPF to determine the best path to a destination, and it allows network administrators to optimize network performance by manipulating the path selection process.
Example To Calculate Path Cost
To calculate the route cost from router R0 to router R1 as shown in figure 7 below:
as you seen above figure 7 the cost of route R1 to R2 which consists GigabitEthernet0/1 and GigabitEthernet0/0 whose cost is 10 and 16 respectively. To calculate the cost the above formula is used:
Cost = 10^8bps/BW bps
Cost = 100000 kbps/BW kbps
cost R1 to R2 = 100000 kbps/10000 kbps +100000 kbps/6000kbps
= 10+16=26
To see the cost of the interface in the cisco packet tracer following commands will be followed:
Router>enable
Router#sh ip route
As shown in figure 8 below the highlighted part is the cost of the route:
Similarly we can see the cost of the another by following the same procedure.
How To Change the Interface Cost?
Changing the OSPF cost can control the determination of the optimal route. There are three methods for modifying the OSPF cost.
- Directly Configuring OSPF Costs
- Modifying Interface Bandwidth (BW)
- Altering the numerator in the formula used to calculate costs (reference-bandwidth)
Directly Configuring OSPF Costs
To configure the OSPF cost directly, by using the following command in interface configuration mode.
Router>en
Router#config tRouter(config-if)#ip ospf cost 20
as shown in figure 9 highlighted part show the new cost of the interface:
Modifying Interface Bandwidth
To modify the interface bandwidth, use the following command in interface configuration mode.
Router>en
Router#config t
Router(config-if)#bandwidth 2000
Router(config-if)#exit
Altering the numerator in the formula used to calculate costs (reference-bandwidth)
To modify the numerator of the cost formula, use the following command in OSPF configuration mode.
(config)#router ospf < process-id >
(config-router)#auto-cost reference-bandwidth < bandwidth >< process-id > : OSPF process id
< bandwidth > : numerator of the cost formula
The following is the conclusion of the OSPF cost:
Configuring OSPF Interface Cost in Cisco
Pre-requisites: Open Shortest Path First (OSPF)
Open Shortest Path First (OSPF) is a routing protocol that exchanges routing information within an autonomous system (AS). it is a link-state protocol that provides a more efficient and scalable way of routing traffic compared to distance vector protocols like RIP.it uses a hierarchical network design with areas, where each area has its own link-state database and all routers within an area have identical information about that area. Dijkstra algorithmis used to calculate the shortest path between two points in a network, based on the link-state information available.