OSPF Tutorial
OSPF Tutorial
OSPF Definition:
Open Shortest Path First (OSPF), is a routing protocol used to determine the correct route
for packets within IP networks. It was designed by the Internet Engineering Task Force to
serve as an Interior Gateway Protocol replacing RIP.
Advantages of OSPF:
1.
2.
3.
4.
5.
6.
Camp Swampy has been given the Class B network 181.160.0.0. The network uses IGRP
as their routing protocol, and they are using an 8 bit subnet mask (255.255.255.0).
Since IGRP does not support VLSM's, Camp Swampy is forced to use an 8 bit mask
throughout their entire network. For networks that contain users, this should be
acceptable, but for network connections, such as the network that connects A and B, this
is a huge waste of IP addresses. We will rebuild their base network using OSPF for one
reason only: To free up IP addresses by using Variable Length Subnet Masks.
This means we are going to have to get into binary, just a little...
Pick a class C equivalent network (in other words, pick a number out of the range
available in their third octet), and use it for network connections within their base
backbone. In this case, lets use 181.160.254.0. We could use a 14 bit subnet mask,
255.255.255.252 (which would only leave two bits for the host part) to get the maximum
number of networks out of the 254 subnet, but that only allows two hosts per network.
Since the Camp Swampy admin regularly put sniffers and other devices on their network
connections, we need to scale the subnet mask back a bit to 13, 255.255.255.248 (leaves
three bits for hosts, a total of 6 possible devices on each net).
You can't use the first or last network to connect to hosts, since the first net is always the
network address for the ENTIRE network (for instance, you don't see many IP addresses
like 181.160.0.1), and the broadcast address for the last subnetted network is also the
broadcast address for the ENTIRE network (you don't see many IP addresses like
181.160.255.1 either). Using a 13 bit subnet mask on 181.160.254.0, you get:
Routers Network
A-B
181.160.254.8 181.160.254.9
181.160.254.10
181.160.254.15
B-C
181.160.254.16 181.160.254.17
181.160.254.18
181.160.254.23
C-D
181.160.254.24 181.160.254.25
181.160.254.26
181.160.254.31
D-E
181.160.254.32 181.160.254.33
181.160.254.34
181.160.254.39
A-C
181.160.254.40 181.160.254.41
181.160.254.42
181.160.254.47
A-D
181.160.254.48 181.160.254.49
181.160.254.50
181.160.254.55
B-D
181.160.254.56 181.160.254.57
181.160.254.58
181.160.254.63
B-E
181.160.254.64 181.160.254.65
181.160.254.66
181.160.254.71
C-E
181.160.254.72 181.160.254.73
181.160.254.74
181.160.254.79
A-E
181.160.254.80 181.160.254.81
181.160.254.82
181.160.254.87
...
...
...
...
...
Here's what is entered on the "A" Router to implement the change to OSPF:
A-router# config t
Enter configuration commands, one per line. End with CNTL/Z.
A-router(config)# interface e 0
A - B connection
A-router(config-if)# ip address 181.160.254.9 255.255.255.248
A-router(config-if)# exit
A-router(config)# interface e 1
A - C connection
A-router(config-if)# ip address 181.160.254.41 255.255.255.248
A-router(config-if)# exit
A-router(config)# interface e 2
A - D connection
A-router(config-if)# ip address 181.160.254.49 255.255.255.248
A-router(config-if)# exit
A-router(config)# interface e 3
A - E connection
A-router(config-if)# ip address 181.160.254.81 255.255.255.248
A-router(config-if)# exit
A-router(config)# no router igrp 200
turn off igrp routing
A-router(config)# router ospf 1
start ospf routing,
Autonomous System # 1
Area 0 is the top level of the OSPF heirarchy. All other areas should border area 0 (what
I'm saying is, if you build an OSPF network where areas do not border area 0, you're on
your own).
Hanging off the backbone routers are other routers, which eventually lead down to the
users. From the backbone router down to the user routers is all one area, and OSPF Link
State Advertisements will only be sent to routers in that area. This can significantly
reduce the size of the routing tables.
The backbone routers are now part of two areas, area 0, and whichever area they support
for the users. This makes them border routers in OSPF parlance. OSPF routers are very
careful to keep track of where their border router is.
To further reduce the size of routing tables, we will impliment route summarization in
version 2.1. Until then, just remember that for route summarization to work correctly, the
range of IP addresses assigned within an area must be consecutive. If Area 1 has all the
networks from 181.160.16.0 to 181.160.63.0, this can be neatly summarized into one line.
To gain a further understanding of the network:
The A Router supports the base commander and her staff. Approximately 6,000
computers are currently connected, and more are expected.
The B Router supports the hospital. Approximately 8,000 computers are
connected.
The C Router supports a handful of buildings: Graphics, Wideband, etc.
Approximately 400 computers.
The D Router supports supply and several tanker squadrons. Approximately
7,000 computers.
The E Router supports everyone else. Approximately 1,000 computers.
After several days of debate, here is the IP addressing scheme that Camp Swampy wants
to use:
181.160.254.0-255
180 *
181.160.1-63.0-255
16,000
181.160.64-127.0-255 16,000
181.160.128-143.0-255 3,800
181.160.144-191.0-255 11,900
181.160.192-207.0-255 3,800
At the end of this chain are the users, all connected into the hub via twisted pair. We will
assign them the 181.160.186.0 network, with an 8 bit mask (255.255.255.0).
Connection Network
Subnet Mask
First IP
Second IP
Broadcast
address
Duser2 Users
181.160.186.0 255.255.255.0
I wont show the commands to put these addresses into the routers, it's pretty simple.
As it stands, Link State Advertisements for routers in Area 4 will stay in Area 4. To
really maximize OSPF, we need to add route summarization:
This gets pretty tedious, though. Fortunately we are saved by the fact that the networks
within Area 4 are contiguous. We can summarize which routes Area 4 is responsible for
by moving the subnet mask up a couple bits. This not only reduces the amount of
commands that must be entered on each router, but also reduces the number of
networks that are shown in routing tables.
Since route summarization must be done using subnet masks, it might help to look at the
IP addresses in binary. Remember that Area 1 was given the 181.160.1.0 to
181.160.63.255 range of addresses:
181.160.1.0
in Binary is 10110101.10100000.00000001.00000000
in Binary is 10110101.10100000.01000000.00000000
If we only had four backbone routers, we could use the same mask on each, and the
routing table would only be five lines long (one for each area). But, alas, we cannot use
the same mask everywhere.
Back to Area 4, which we were working on in version 2.0. It has been assigned the range
of addresses from 181.160.144.0 to 181.160.191.255. It takes three lines to summarize
this network, using the binary bit in the 16 position for 181.160.144 through 181.160.191 :
181.160.144.0
181.160.159.0
in Binary is 10110101.10100000.10010000.00000000
in Binary is 10110101.10100000.10011111.00000000
181.160.160.0
181.160.175.0
in Binary is 10110101.10100000.10100000.00000000
in Binary is 10110101.10100000.10101111.00000000
181.160.176.0
181.160.191.0
in Binary is 10110101.10100000.10110000.00000000
in Binary is 10110101.10100000.10111111.00000000
Areas
network 181.160.144.0 0.0.15.255 area 1
181.160.159.255
area 1 range 181.160.144.0 255.255.240.0
routing table
network 181.160.160.0 0.0.15.255 area 1
181.160.175.255
area 1 range 181.160.160.0 255.255.240.0
routing table
network 181.160.176.0 0.0.15.255 area 1
181.160.191.255
181.160.144.0 through
Summarize in the
181.160.160.0 through
Summarize in the
181.160.176.0 through
To make sure you believe me when I say this is all worth it:
O IA
O IA
181.160.254.8 255.255.255.248
[110/1582] via 181.160.144.10, 00:26:54, Ethernet0/0
181.160.254.24 255.255.255.248
[110/1582] via 181.160.144.10, 00:26:54, Ethernet0/0
.....
Well, that's just about it, kids. Here's the router configurations for:
C Router
D Router
Din1
Duser2
away. The router can then use this knowledge to determine the best route for traffic, and
can avoid sending data across the network if that network is down.
Multicast Addresses
Class A networks are identified with a 1 - 127 in the first octet.
Class B networks are identified with a 128 - 191 in the first octet.
Class C networks are identified with a 192 - 223 in the first octet.
Class D networks are identified with a 224 - 239 in the first octet, and are reserved for
multicast addresses.
In OSPF, two multicast addresses are used. When an OSPF area is started, one router is
elected the Designated Router (DR), and another is made the Backup Designated Router
(BDR). The Designated Router tells all the other routers about changes in the network by
sending out Link State Advertisements (LSA's) on multicast address 224.0.0.5. When a
router notices a change in the network, it sends this information out on 224.0.0.6, the
multicast address reserved for the DR and the BDR.
When a new router is added to the net, it announces it's presence to the world by sending
out a hello message on 224.0.0.5. If it doesn't get a response, it becomes the new
Designated Router. If a Designated Router responds to the hello message, the new router
will use 224.0.0.6 from then on to send out LSA's.
Wasted IP addresses
Network protocols that do not support Variable Length Subnet Masks put network
administrators in an awkward position. If a standard 8 bit mask is used throughout the
Class B network (255.255.255.0), then IP addresses will be wasted on network
connections.
For instance, for the network that connects the "A" router to the "B" router (A,B), if it is
given 181.160.187.0, it will waste 252 IP addresses.