OSPF Configuration Step by Step Guide
Assign IP address to PC
Double click PC0 and click Desktop menu item and click IP Configuration. Assign IP
address [Link]/8 to PC0.
Repeat same process for Server0 and assign IP address [Link]/8.
Assign IP address to interfaces of routers
Double click Router0 and click CLI and press Enter key to access the command prompt
of Router0.
Four interfaces FastEthernet0/0, FastEthernet0/1, Serial 0/0/0 and Serial0/0/1 of Router0
are used in this topology. By default interfaces on router are remain administratively
down during the start up.
We need to configure IP address and other parameters on interfaces before we could
actually use them for routing. Interface mode is used to assign the IP address and other
parameters. Interface mode can be accessed from global configuration mode. Following
commands are used to access the global configuration mode.
Router>enable
Router# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#
From global configuration mode we can enter in interface mode. From there we can
configure the interface. Following commands will assign IP address on FastEthernet0/0
and FastEthernet0/1.
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address [Link] [Link]
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface fastEthernet 0/1
Router(config-if)#ip address [Link] [Link]
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#
interface fastEthernet 0/0 command is used to enter in interface mode.
ip address [Link] [Link] command would assign IP address to interface.
no shutdown command would bring the interface up.
exit command is used to return in global configuration mode.
Serial interface needs two additional parameters clock rate and bandwidth. Every
serial cable has two ends DTE and DCE. These parameters are always configured at DCE
end.
We can use show controllers interface command from privilege mode to check the
cable’s end.
Router#show controllers serial 0/0/0
Interface Serial0/0/0
Hardware is PowerQUICC MPC860
DCE V.35, clock rate 2000000
[Output omitted]
Fourth line of output confirms that DCE end of serial cable is attached. If you see DTE
here instead of DCE skip these parameters.
Now we have necessary information let’s assign IP address to serial interfaces.
Router# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface serial 0/0/0
Router(config-if)#ip address [Link] [Link]
Router(config-if)#clock rate 64000
Router(config-if)#bandwidth 64
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface serial 0/0/1
Router(config-if)#ip address [Link] [Link]
Router(config-if)#no shutdown
Router(config-if)#exit
Router#configure terminal Command is used to enter in global configuration mode.
Router(config)#interface serial 0/0/0 Command is used to enter in interface mode.
Router(config-if)#ip address [Link] [Link] Command assigns IP
address to interface. For serial link we usually use IP address from /30 subnet.
Router(config-if)#clock rate 64000 In real life environment this parameter controls
the data flow between serial links and need to be set at service provider’s end. In lab
environment we need not to worry about this value. We can use any valid clock rate
here.
Router(config-if)#bandwidth 64 Bandwidth works as an influencer. It is used to
influence the metric calculation of OSPF or any other routing protocol which uses
bandwidth parameter in route selection process. Serial interface has default bandwidth
of 1544Kbps. To explain, how bandwidth influence route selection process we will
configure (64Kbps) bandwidth on three serial DCE interfaces of our network; R0’s
Se0/0/0, R1’s Se0/0/1 and R2’s Se0/0/0.
Router(config-if)#no shutdown Command brings interface up.
Router(config-if)#exit Command is used to return in global configuration mode.
We will use same commands to assign IP addresses on interfaces of remaining routers.
Router1
Router2
As I mention earlier, serial interface has a default bandwidth of 1544Kbps. If we don’t
assign any custom bandwidth, router would use default bandwidth. To see this feature
in action we will not assign bandwidth on remaining routers.
Router6
Router5
Router3
Router4
Great job we have finished our half journey. Now routers have information about the
networks that they have on their own interfaces. Routers will not exchange this
information between them on their own. We need to implement OSPF routing protocol
that will insist them to share this information.
To be on same track I have uploaded my practice topology. Use this if you want to skip
above IP configuration part.
Download OSPF Practice Topology with IP configuration
Configure OSPF routing protocol
Enabling OSPF is a two steps process:-
Enable OSPF routing protocol from global configuration mode.
Tell OSPF which interfaces we want to include.
For these steps following commands are used respectively.
Router(config)# router ospf process_ID
Router(config-router)# network IP_network_# [wild card mask] Area
Number area number
Router(config)# router ospf process ID
This command will enable OSPF routing protocol in router. Process ID is a positive
integer. We can use any number from 1 to 65,535. Process ID is locally significant. We
can run multiple OSPF process on same router. Process ID is used to differentiate
between them. Process ID need not to match on all routers.
Router(config-router)# network IP_network_# [wildcard_mask] area [area
number]
Network command allows us to specify the interfaces which we want to include in OSPF
process. This command accepts three arguments network number, wildcard mask and
area number.
Network number
Network number is network ID. We can use any particular host IP address or network IP
address. For example we can use [Link] (host IP address) or we can use [Link]
(Network IP address). While targeting a specific interface usually we use host IP address
(configured on that interface).
While targeting multiple interfaces, we use network IP address. So any interface that
belongs to specified network ID will be selected.
Wildcard mask
Wildcard mask are used with network ID to filter the interfaces. Wildcard mask is
different from subnet mask. Subnet mask is used to separate the network portion and
host portion in IP address. While wildcard mask is used to match corresponding octet in
network portion. Wildcard mask tells OSPF the part of network address that must be
matched. Wildcard masks are explained with examples in access list tutorials of this
category.
Key points
0 (Decimal – octet format) Wildcard mask indicates that corresponding octet in
network address must be matched exactly.
255 (Decimal – octet format) Wildcard mask indicates that we don’t care about
corresponding octet in network address.
For example
0 (Binary – bit format) Wildcard mask indicates that corresponding bit in network
address must be matched exactly.
255 (Binary – bit format) Wildcard mask indicates that we don’t care about
corresponding bit in network address.
OSPF is a classless protocol. With wildcard we can also filter Subnetted networks. In
classes implementation usually we use Subnetted networks. For example consider
following figure
We have four networks [Link]/24, [Link]/24, [Link]/24 and
[Link]/24 subnetted from single class B network [Link]/16. Classful
configuration does not understand the concept of subnetting. In classful configuration
all these networks belong to a single network. Classful configuration works only with in
default boundary of mask. Default boundary of this address is 16 bits. So a classful
routing protocol will match only first 16 bits (172.168.x.y) of network address. A classful
routing protocol such as RIP cannot distinguish between different Subnetted networks.
A classless routing protocol such as OSPF goes beyond the default boundary of mask
and work well with Subnetted networks. With wildcard mask we can easily filter
Subnetted networks.
With wildcard we are no longer limited with default boundaries. We can match
Subnetted networks as well as default networks.
For example we want to exclude serial interfaces in above configuration. We can use a
wildcard mask of [Link] to match the subnet mask of /24.
Router(config-router)# network [Link] [Link]
Router(config-router)# network [Link] [Link]
Above commands will ask router to match /24 bits of address instead of default /16 bits.
Now router will look for 172.168.1.x and 172.168.2.x network. Our serial interfaces have
[Link]/24 and [Link]/24 networks which do not fall in these search criteria.
Let’s take one more example, if we use following network command, which interfaces
would be selected.
Router(config-router)# network [Link] [Link]
In this case valid host IP addresses are [Link] and [Link]. So any interface that
has these IP address would be selected. /30 network is usually used for serial link
connection which need only two valid host IP addresses; one for each end.
If you are unfamiliar with wildcard mask, I suggest you to check our tutorials on access
lists configuration in this category. In those tutorials wildcard masks are explained in
detail with examples.
For this tutorial let’s move on third argument. Third argument which network command
accept is area number. This parameter say router to put matched interface in specified
area. OSPF areas are explained in second part this article.
Now we know the essential commands for configuration. Let’s implement them in our
network.
OSPF configuration
Router0
Router1
Router2
Router6
Router5
Router4
Router3
That’s it. Our network is ready to take the advantage of OSPF routing. To verify the
setup we will use ping command. ping command is used to test the connectivity
between two devices.
We have two routes between source and destination. tracert command is used to know
the route which is used to get the destination.
Access the command prompt of PC1 and use ping command to test the connectivity
from Server0. After that use tracert command to print the taken path.
Great! We have successfully implemented OSFP routing in our network.