router ospf
Command
router ospf <process id>
UseThe router ospf (Open Shortest Path First) command is necessary to enable ospf. OSPF must be enabled before carrying out any of the ospf commands. OSPF was designed to be an Interior Gateway Protocol replacing RIP.
Routers that use OSPF check the status of other routers on the network by sending a "hello" packet at set intervals. When a router does not respond to a hello packet, it is considered to be dead and a routing update is sent to every router on the network using a multicast address.
When OSPF is running on a network it uses very little bandwidth, only sending "hello" packets. When an outage occurs, OSPF floods the network sending out routing updates to every router. Those routers then send out the routing update, flooding the network. OSPF runs almost silent when possible, and floods the network when necessary to ensure routing information gets propagated throughout the network as quickly as possible.
Syntax
Router(config)#router ospf
Example
In this example, OSPF is enabled on the routers. First, we use the show ip route command to help determine the network layout.
R1#sh ip route
Codes: 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
i - IS-IS, su - IS-IS summary, 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 not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 2 subnets
C 10.1.1.0 is directly connected, FastEthernet0/0
R1#
|
Next, we set router ospf on R1.
R1(config)#router ospf 1
R1(config-router)#network 10.1.1.0 0.0.0.255 area 0
R1(config-router)#exit
R1(config)#exit
R1# |
After that, the same is done with R2.
R2(config)#router ospf 1
R2(config-router)#network 10.1.1.0 0.0.0.255 area 0
R2(config-router)#exit
R2(config)#exit
R2# |
We also need to configure ospf on R2 for R3.
R2(config)#router ospf 1
R2(config-router)#network 10.2.2.0 0.0.0.255 area 0
R2(config-router)#exit
R2(config)#exit
R2# |
Again we need to do the same for R3.
R3(config)#router ospf 1
R3(config-router)#network 10.2.2.0 0.0.0.255 area 0
R3(config-router)#exit
R3(config)#exit
R3# |
Now if we type show ip route we see that OSPF is enabled and sending routes
R1#sh ip route
Codes: 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
i - IS-IS, su - IS-IS summary, 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 not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 2 subnets
O 10.2.2.0 [110/2] via 10.1.1.2, 00:05:22, FastEthernet0/0
C 10.1.1.0 is directly connected, FastEthernet0/0
R1# |
Back to commands department
|