Chapter Routing Concepts
IP Static Routing
03 Single-Area OSPFv2
Module Objectives
Topic Title Topic Objective
Path Determination Explain how routers determine the best path.
Packet Forwarding Explain how routers forward packets to the destination.
Basic Router Configuration Review Configure basic settings on a router.
IP Routing Table Describe the structure of a routing table.
Static and Dynamic Routing Compare static and dynamic routing concepts.
Static Routes Describe the command syntax for static routes.
Configure IP Static Routes Configure IPv4 and IPv6 static routes.
Configure IP Default Static Routes Configure IPv4 and IPv6 default static routes.
Configure Floating Static Routes Configure a floating static route to provide a backup connection.
Configure IPv4 and IPv6 static host routes that direct traffic to a specific
Configure Static Host Routes
host.
Module Objectives
Topic Title Topic Objective
OSPF Features and Characteristics Describe basic OSPF features and characteristics.
OSPF Packets Describe the OSPF packet types used in single-area OSPF.
OSPF Operation Explain how single-area OSPF operates.
OSPF Features and Characteristics Describe basic OSPF features and characteristics.
OSPF Router ID Configure an OSPFv2 router ID.
Point-to-Point OSPF Networks Configure single-area OSPFv2 in a point-to-point network.
Configure the OSPF interface priority to influence the DR/BDR election in a
Multiaccess OSPF Networks
multiaccess network.
Modify Single-Area OSPFv2 Implement modifications to change the operation of single-area OSPFv2.
Default Route Propagation Configure OSPF to propagate a default route.
Verify Single-Area OSPFv2 Verify a single-area OSPFv2 implementation.
3.1 Path Determination
Two Functions of a Router
When a router receives an IP packet on one interface, it
determines which interface to use to forward the packet to the
destination. This is known as routing. The interface that the
router uses to forward the packet may be the final destination, or
it may be a network connected to another router that is used to
reach the destination network. Each network that a router
connects to typically requires a separate interface, but this may
not always be the case.
The primary functions of a router are to determine the best path
to forward packets based on the information in its routing table,
and to forward packets toward their destination.
Router Functions Example
The router uses its IP
routing table to determine
which path (route) to use
to forward a packet. R1 and
R2 will use their respective
IP routing tables to first
determine the best path,
and then forward the
packet.
Best Path Equals Longest Match
• The best path in the routing table is also known as the longest match.
• The routing table contains route entries consisting of a prefix (network
address) and prefix length. For there to be a match between the
destination IP address of a packet and a route in the routing table, a
minimum number of far-left bits must match between the IP address of
the packet and the route in the routing table. The prefix length of the route
in the routing table is used to determine the minimum number of far-left
bits that must match.
• The longest match is the route in the routing table that has the greatest
number of far-left matching bits with the destination IP address of the
packet. The longest match is always the preferred route.
Note: The term prefix length will be used to refer to the network portion of
both IPv4 and IPv6 addresses.
IPv4 Longest Match Example
In the table, an IPv4 packet has the destination IPv4 address [Link]. The
router has three route entries in its IPv4 routing table that match this packet:
[Link]/12, [Link]/18, and [Link]/26. Of the three routes,
[Link]/26 has the longest match and would be chosen to forward the
packet. For any of these routes to be considered a match there must be at
least the number of matching bits indicated by the subnet mask of the route.
Destination IPv4 Address Address in Binary
[Link] 10101100.00010000.00000000.00001010
Route Entry Prefix/Prefix Length Address in Binary
1 [Link]/12 10101100.00010000.00000000.00000000
2 [Link]/18 10101100.00010000.00000000.00000000
3 [Link]/26 10101100.00010000.00000000.00000000
IPv6 Longest Match Example
An IPv6 packet has the destination IPv6 address 2001:db8:c000::99. This
example shows three route entries, but only two of them are a valid match,
with one of those being the longest match. The first two route entries have
prefix lengths that have the required number of matching bits as indicated by
the prefix length. The third route entry is not a match because its /64 prefix
requires 64 matching bits.
Destination 2001:db8:c000::99/48
Route Entry Prefix/Prefix Length Does it match?
1 2001:db8:c000::/40 Match of 40 bits
2 2001:db8:c000::/48 Match of 48 bits (longest match)
3 2001:db8:c000:5555::/64 Does not match 64 bits
Build the Routing Table
Directly Connected Networks: Added to the routing table when a local interface is
configured with an IP address and subnet mask (prefix length) and is active (up and up).
Remote Networks: Networks that are not directly connected to the router. Routers learn
about remote networks in two ways:
• Static routes - Added to the routing table when a route is manually configured.
• Dynamic routing protocols - Added to the routing table when routing protocols dynamically learn
about the remote network.
Default Route: Specifies a next-hop router to use when the routing table does not contain a
specific route that matches the destination IP address. The default route can be entered
manually as a static route, or learned automatically from a dynamic routing protocol.
• A default route has a /0 prefix length. This means that no bits need to match the destination IP
address for this route entry to be used. If there are no routes with a match longer than 0 bits, the
default route is used to forward the packet. The default route is sometimes referred to as a
gateway of last resort.
3.2 Packet Forwarding
Packet Forwarding Decision Process
1. The data link frame with an
encapsulated IP packet arrives
on the ingress interface.
2. The router examines the
destination IP address in the
packet header and consults its
IP routing table.
3. The router finds the longest
matching prefix in the routing
table.
4. The router encapsulates the
packet in a data link frame and
forwards it out the egress
interface. The destination could
be a device connected to the
network or a next-hop router.
5. However, if there is no
matching route entry the packet
is dropped.
Packet Forwarding Decision Process (Cont.)
After a router has determined the best path, it could do the following:
Forward the Packet to a Device on a Directly Connected Network
• If the route entry indicates that the egress interface is a directly connected
network, the packet can be forwarded directly to the destination device.
Typically this is an Ethernet LAN.
• To encapsulate the packet in the Ethernet frame, the router needs to
determine the destination MAC address associated with the destination IP
address of the packet. The process varies based on whether the packet is
an IPv4 or IPv6 packet.
Packet Forwarding Decision Process (Cont.)
After a router has determined the best path, it could do the following:
Forward the Packet to a Next-Hop Router
• If the route entry indicates that the destination IP address is on a remote
network, meaning a device on network that is not directly connected. The
packet must be forwarded to the next-hop router. The next-hop address is
indicated in the route entry.
• If the forwarding router and the next-hop router are on an Ethernet
network, a similar process (ARP and ICMPv6 Neighbor Discovery) will occur
for determining the destination MAC address of the packet as described
previously. The difference is that the router will search for the IP address of
the next-hop router in its ARP table or neighbor cache, instead of the
destination IP address of the packet.
Note: This process will vary for other types of Layer 2 networks.
Packet Forwarding Decision Process (Cont.)
After a router has determined the best path, it could do the following:
Drop the Packet - No Match in Routing Table
• If there is no match between the destination IP address and a prefix in the
routing table, and if there is no default route, the packet will be dropped.
End-to-End Packet Forwarding
The primary responsibility of the packet forwarding function is to encapsulate
packets in the appropriate data link frame type for the outgoing interface. For
example, the data link frame format for a serial link could be Point-to-Point
(PPP) protocol, High-Level Data Link Control (HDLC) protocol, or some other
Layer 2 protocol.
Packet Forwarding Mechanisms
The primary responsibility of the packet forwarding function is to encapsulate
packets in the appropriate data link frame type for the outgoing interface. The
more efficiently a router can perform this task, the faster packets can be
forwarded by the router.
Routers support the following three packet forwarding mechanisms:
• Process switching
• Fast switching
• Cisco Express Forwarding (CEF)
Packet Forwarding Mechanisms (Cont.)
Process Switching: An older packet forwarding mechanism still available for
Cisco routers. When a packet arrives on an interface, it is forwarded to the
control plane where the CPU matches the destination address with an entry in
its routing table, and then determines the exit interface and forwards the
packet. It is important to understand that the router does this for every
packet, even if the destination is the same for a stream of packets.
Packet Forwarding Mechanisms (Cont.)
• Fast Switching: Another, older packet forwarding mechanism which was
the successor to process switching. Fast switching uses a fast-switching
cache to store next-hop information. When a packet arrives on an
interface, it is forwarded to the control plane where the CPU searches for a
match in the fast-switching cache. If it is not there, it is process-switched
and forwarded to the exit interface. The flow information for the packet is
then stored in the fast-switching cache. If another packet going to the
same destination arrives on an interface, the next-hop information in the
cache is re-used without CPU intervention.
Packet Forwarding Mechanisms (Cont.)
• Cisco Express Forwarding (CEF): The most recent and default Cisco IOS
packet-forwarding mechanism. CEF builds a Forwarding Information Base
(FIB), and an adjacency table. The table entries are not packet-triggered
like fast switching but change-triggered, such as when something changes
in the network topology. When a network has converged, the FIB and
adjacency tables contain all the information that a router would have to
consider when forwarding a packet.
3.3 Basic Router Configuration Review
Topology
The topology in the figure will be used for configuration and verification
examples. It will also be used in the next topic to discuss the IP routing table.
Configuration Commands
R1(config)# ipv6 unicast-routing
R1(config)# interface gigabitethernet 0/0/0
Router> enable R1(config-if)# description Link to LAN 1
Router# configure terminal R1(config-if)# ip address [Link] [Link]
Enter configuration commands, one per line. End with R1(config-if)# ipv6 address 2001:db8:acad:1::1/64
CNTL/Z. R1(config-if)# ipv6 address fe80::1:a link-local
Router(config)# hostname R1 R1(config-if)# no shutdown
R1(config)# enable secret class R1(config-if)# exit
R1(config)# line console 0 R1(config)# interface gigabitethernet 0/0/1
R1(config-line)# logging synchronous R1(config-if)# description Link to LAN 2
R1(config-line)# password cisco R1(config-if)# ip address [Link] [Link]
R1(config-line)# login R1(config-if)# ipv6 address 2001:db8:acad:2::1/64
R1(config-line)# exit R1(config-if)# ipv6 address fe80::1:b link-local
R1(config)# line vty 0 4 R1(config-if)# no shutdown
R1(config-line)# password cisco R1(config-if)# exit
R1(config-line)# login R1(config)# interface serial 0/1/1
R1(config-line)# transport input ssh telnet R1(config-if)# description Link to R2
R1(config-line)# exit R1(config-if)# ip address [Link] [Link]
R1(config)# service password-encryption R1(config)# R1(config-if)# ipv6 address 2001:db8:acad:3::1/64
banner motd # R1(config-if)# ipv6 address fe80::1:c link-local
Enter TEXT message. End with a new line and the # R1(config-if)# no shutdown
*********************************************** R1(config-if)# exit
WARNING: Unauthorized access is prohibited! R1# copy running-config startup-config
*********************************************** Destination filename [startup-config]?
# Building configuration...
[OK]
R1#
Verification Commands
Common verification commands include the following:
• show ip interface brief
• show running-config interface interface-type number
• show interfaces
• show ip interface
• show ip route
• ping
In each case, replace ip with ipv6 for the IPv6 version of the command.
Filter Command Output
Filtering commands can be used to display specific sections of output. To
enable the filtering command, enter a pipe (|) character after
the show command and then enter a filtering parameter and a filtering
expression.
The filtering parameters that can be configured after the pipe include:
• section - This displays the entire section that starts with the filtering
expression.
• include - This includes all output lines that match the filtering expression.
• exclude - This excludes all output lines that match the filtering expression.
• begin - This displays all the output lines from a certain point, starting with
the line that matches the filtering expression.
Note: Output filters can be used in combination with any show command.
3.4 IP Routing Table
Route Sources
A routing table contains a list of routes to known networks (prefixes and prefix
lengths). The source of this information is derived from the following:
• Directly connected networks
• Static routes
• Dynamic routing protocols
The source for each route in the routing table is identified by a code. Common
codes include the following:
• L - Identifies the address assigned to a router interface.
• C - Identifies a directly connected network.
• S - Identifies a static route created to reach a specific network.
• O - Identifies a dynamically learned network from another router using the OSPF
routing protocol.
• * - This route is a candidate for a default route.
Routing Table Principles
There are three routing table principles as described in the table. These are
issues that are addressed by the proper configuration of dynamic routing
protocols or static routes on all the routers between the source and
destination devices.
Routing Table Principle Example
Every router makes its decision •R1 can only forward packets using its own routing table.
alone, based on the information it •R1 does not know what routes are in the routing tables of
has in its own routing table. other routers (e.g., R2).
The information in a routing table
Just because R1 has route in its routing table to a network
of one router does not necessarily
in the internet via R2, that does not mean that R2 knows
match the routing table of another
about that same network.
router.
R1 receives a packet with the destination IP address of PC1
Routing information about a path and the source IP address of PC3. Just because R1 knows
does not provide return routing to forward the packet out its G0/0/0 interface, doesn’t
information. necessarily mean that it knows how to forward packets
originating from PC1 back to the remote network of PC3
Routing Table Entries
In the figure, the numbers identify the following
information:
• Route source - This identifies how the route was
learned.
• Destination network (prefix and prefix length) - This
identifies the address of the remote network.
• Administrative distance - This identifies the
trustworthiness of the route source. Lower values
indicate preferred route source.
• Metric - This identifies the value assigned to reach
the remote network. Lower values indicate preferred
routes. Note: The prefix length of the destination
• Next-hop - This identifies the IP address of the next network specifies the minimum number of
router to which the packet would be forwarded. far-left bits that must match between the IP
• Route timestamp - This identifies how much time address of the packet and the destination
has passed since the route was learned. network (prefix) for this route to be used.
• Exit interface - This identifies the egress interface to
use for outgoing packets to reach their final
destination.
Directly Connected Networks
To learn about any remote networks, the router must have at least one active
interface configured with an IP address and subnet mask (prefix length). This
is known as a directly connected network or a directly connected route.
Routers add a directly connected route to its routing table when an interface
is configured with an IP address and is activated.
• A directly connected network is denoted by a status code of C in the
routing table. The route contains a network prefix and prefix length.
• The routing table also contains a local route for each of its directly
connected networks, indicated by the status code of L.
• For IPv4 local routes the prefix length is /32 and for IPv6 local routes the
prefix length is /128. This means the destination IP address of the packet
must match all the bits in the local route for this route to be a match. The
purpose of the local route is to efficiently determine when it receives a
packet for the interface instead of a packet that needs to be forwarded.
Static Routes
After directly connected interfaces are configured and added to the routing
table, static or dynamic routing can be implemented for accessing remote
networks. Static routes are manually configured. They define an explicit path
between two networking devices. They are not automatically updated and
must be manually reconfigured if the network topology changes.
Static routing has three primary uses:
• It provides ease of routing table maintenance in smaller networks that are
not expected to grow significantly.
• It uses a single default route to represent a path to any network that does
not have a more specific match with another route in the routing table.
Default routes are used to send traffic to any destination beyond the next
upstream router.
• It routes to and from stub networks. A stub network is a network accessed
by a single route, and the router has only one neighbor.
Static Routes in the IP Routing Table
The topology in the figure is simplified to show only one LAN attached to each router. The
figure shows IPv4 and IPv6 static routes configured on R1 to reach the [Link]/24 and
2001:db8:acad:4::/64 networks on R2.
Dynamic Routing Protocols
Dynamic routing protocols are used by routers to automatically share information
about the reachability and status of remote networks. Dynamic routing protocols
perform several activities, including network discovery and maintaining routing tables.
Dynamic Routes in the Routing Table
OSPF is now being used in our sample topology to dynamically learn all the
networks connected to R1 and R2. The routing table entries use the status
code of O to indicate the route was learned by the OSPF routing protocol.
Both entries also include the IP address of the next-hop router, via ip-address.
Note: IPv6 routing protocols use the link-local address of the next-hop router.
Note: OSPF routing configuration for IPv4 and IPv6 is beyond the scope of this course.
R1# show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external,
O - OSPF, IA - OSPF inter area
(output omitted for brevity)
O [Link]/24 [110/50] via [Link], 00:24:22, Serial0/1/1
O [Link]/24 [110/50] via [Link], 00:24:15, Serial0/1/1
R1# show ipv6 route
IPv6 Routing Table - default - 10 entries
(Output omitted)
NDr - Redirect, RL - RPL, O - OSPF Intra, OI - OSPF Inter
O 2001:DB8:ACAD:4::/64 [110/50]
via FE80::2:C, Serial0/1/1
O 2001:DB8:ACAD:5::/64 [110/50]
via FE80::2:C, Serial0/1/1
Default Route
The default route specifies a next-hop router to use when the routing table does not
contain a specific route that matches the destination IP address. A default route can be
either a static route or learned automatically from a dynamic routing protocol. A
default route has an IPv4 route entry of [Link]/0 or an IPv6 route entry of ::/0. This
means that zero or no bits need to match between the destination IP address and the
default route.
Structure of an IPv4 Routing Table
IPv4 was standardized using the now obsolete classful addressing architecture.
The IPv4 routing table is organized using this same classful structure. Although
the lookup process no longer uses classes, the structure of the IPv4 routing
table still retains in this format.
An indented entry is known as a child route. A route entry is indented if it is
the subnet of a classful address (class A, B or C network). Directly connected
networks will always be indented (child routes) because the local address of
the interface is always entered in the routing table as a /32. The child route
will include the route source and all the forwarding information such as the
next-hop address. The classful network address of this subnet will be shown
above the route entry, less indented, and without a source code. That route is
known as a parent route.
Structure of an IPv4 Routing Table
• An indented entry is known as a child route.
A route entry is indented if it is the subnet Router# show ip route
of a classful address (class A, B or C (Output omitted)
[Link]/24 is variably..
network). C [Link]/24 is direct..
• Directly connected networks will always be L [Link]/32 is direct..
O [Link]/24 [110/65]..
indented (child routes) because the local O [Link]/24 [110/65]..
address of the interface is always entered in [Link]/24 is variab..
the routing table as a /32. C [Link]/30 is direct..
L [Link]/32 is direct..
• The child route will include the route source [Link]/24 is variably..
and all the forwarding information such as C [Link]/30 is direct..
the next-hop address. L [Link]/32 is direct..
[Link]/30 is subnette..
• The classful network address of this subnet O [Link]/30 [110/128]..
will be shown above the route entry, less Router#
indented, and without a source code. That
route is known as a parent route.
Structure of an IPv4 Routing Table
R1# show ipv6 route
(output omitted for brevity)
OE2 ::/0 [110/1], tag 2
The concept of classful via FE80::2:C, Serial0/0/1
addressing was never part of C 2001:DB8:ACAD:1::/64 [0/0]
via GigabitEthernet0/0/0, directly connected
IPv6, so the structure of an IPv6 L 2001:DB8:ACAD:1::1/128 [0/0]
via GigabitEthernet0/0/0, receive
routing table is very straight C 2001:DB8:ACAD:2::/64 [0/0]
forward. Every IPv6 route entry via GigabitEthernet0/0/1, directly connected
L 2001:DB8:ACAD:2::1/128 [0/0]
is formatted and aligned the via GigabitEthernet0/0/1, receive
C 2001:DB8:ACAD:3::/64 [0/0]
same way. via Serial0/1/1, directly connected
L 2001:DB8:ACAD:3::1/128 [0/0]
via Serial0/1/1, receive
O 2001:DB8:ACAD:4::/64 [110/50]
via FE80::2:C, Serial0/1/1
O 2001:DB8:ACAD:5::/64 [110/50]
via FE80::2:C, Serial0/1/1
L FF00::/8 [0/0]
via Null0, receive
R1#
Administrative Distance
A route entry for a specific network address (prefix and prefix length) can only
appear once in the routing table. However, it is possible that the routing table
learns about the same network address from more than one routing source.
Except for very specific circumstances, only one dynamic routing protocol
should be implemented on a router. Each routing protocol may decide on a
different path to reach the destination based on the metric of that routing
protocol.
This raises a few questions, such as the following:
• How does the router know which source to use?
• Which route should it install in the routing table?
Cisco IOS uses what is known as the administrative distance (AD) to determine
the route to install into the IP routing table. The AD represents the
"trustworthiness" of the route. The lower the AD, the more trustworthy the
route source.
Administrative Distance (Cont.)
Route Source Administrative Distance
Directly connected 0
The table lists various routing
protocols and their associated Static route 1
ADs. EIGRP summary route 5
External BGP 20
Internal EIGRP 90
OSPF 110
IS-IS 115
RIP 120
External EIGRP 170
Internal BGP 200
3.5 Static and Dynamic Routing
Static or Dynamic?
Static and dynamic routing are not mutually exclusive. Rather, most networks
use a combination of dynamic routing protocols and static routes.
Static routes are commonly used in the following scenarios:
• As a default route forwarding packets to a service provider
• For routes outside the routing domain and not learned by the dynamic
routing protocol
• When the network administrator wants to explicitly define the path for a
specific network
• For routing between stub networks
Static routes are useful for smaller networks with only one path to an outside
network. They also provide security in a larger network for certain types of
traffic, or links to other networks that need more control.
Static or Dynamic? (Cont.)
Dynamic routing protocols are implemented in any type of network consisting
of more than just a few routers. Dynamic routing protocols are scalable and
automatically determine better routes if there is a change in the topology.
Dynamic routing protocols are commonly used in the following scenarios:
• In networks consisting of more than just a few routers
• When a change in the network topology requires the network to automatically
determine another path
• For scalability. As the network grows, the dynamic routing protocol automatically
learns about any new networks.
Static or Dynamic? (Cont.)
The table shows a comparison of some the differences between dynamic and
static routing.
Feature Dynamic Routing Static Routing
Configuration complexity Independent of network size Increases with network size
Automatically adapts to topology
Topology changes Administrator intervention required
changes
Suitable for simple to complex
Scalability Suitable for simple topologies
network topologies
Security Security must be configured Security is inherent
Uses CPU, memory, and link
Resource Usage No additional resources needed
bandwidth
Route depends on topology and Explicitly defined by the
Path Predictability
routing protocol used administrator
Dynamic Routing Evolution
Dynamic routing protocols have been used in networks since the late 1980s.
One of the first routing protocols was RIP. RIPv1 was released in 1988, but
some of the basic algorithms within the protocol were used on the Advanced
Research Projects Agency Network (ARPANET) as early as 1969. As networks
evolved and became more complex, new routing protocols emerged.
Dynamic Routing Evolution (Cont.)
The table classifies the current routing protocols. Interior Gateway Protocols (IGPs) are
routing protocols used to exchange routing information within a routing domain
administered by a single organization. There is only one EGP and it is BGP. BGP is used
to exchange routing information between different organizations, known as
autonomous systems (AS). BGP is used by ISPs to route packets over the internet.
Distance vector, link-state, and path vector routing protocols refer to the type of
routing algorithm used to determine best path.
Interior Gateway Protocols Exterior Gateway Protocols
Distance Vector Link-State Path Vector
IPv4 RIPv2 EIGRP OSPFv2 IS-IS BGP-4
IPv6 RIPng EIGRP for OSPFv3 IS-IS for BGP-MP
IPv6 IPv6
Dynamic Routing Protocol Concepts
A routing protocol is a set of processes, algorithms, and messages that are
used to exchange routing information and populate the routing table with the
choice of best paths. The purpose of dynamic routing protocols includes the
following:
• Discovery of remote networks
• Maintaining up-to-date routing information
• Choosing the best path to destination networks
• Ability to find a new best path if the current path is no longer available
Dynamic Routing Protocol Concepts (Cont.)
The main components of dynamic routing protocols include the following:
• Data structures - Routing protocols typically use tables or databases for their
operations. This information is kept in RAM.
• Routing protocol messages - Routing protocols use various types of messages to
discover neighboring routers, exchange routing information, and other tasks to
learn and maintain accurate information about the network.
• Algorithm - An algorithm is a finite list of steps used to accomplish a task. Routing
protocols use algorithms for facilitating routing information and for the best path
determination.
Routing protocols determine the best path, or route, to each network. That
route is then offered to the routing table. The route will be installed in the
routing table if there is not another routing source with a lower AD.
Best Path
The best path is selected by a routing protocol based on the value or metric it
uses to determine the distance to reach a network. A metric is the
quantitative value used to measure the distance to a given network. The best
path to a network is the path with the lowest metric.
Dynamic routing protocols typically use their own rules and metrics to build
and update routing tables. The following table lists common dynamic
protocols and their metrics.
Routing Protocol Metric
•The metric is “hop count”.
Routing Information Protocol
•Each router along a path adds a hop to the hop count.
(RIP)
•A maximum of 15 hops allowed.
•The metric is “cost” which is the based on the cumulative bandwidth
from source to destination.
Open Shortest Path First (OSPF)
•Faster links are assigned lower costs compared to slower (higher cost)
links.
Enhanced Interior Gateway •It calculates a metric based on the slowest bandwidth and delay values.
Routing Protocol (EIGRP) •It could also include load and reliability into the metric calculation.
Load Balancing
When a router has two or more paths to a destination with equal cost metrics,
then the router forwards the packets using both paths equally. This is called
equal cost load balancing.
• The routing table contains the single destination network, but has multiple
exit interfaces, one for each equal cost path. The router forwards packets
using the multiple exit interfaces listed in the routing table.
• If configured correctly, load balancing can increase the effectiveness and
performance of the network.
• Equal cost load balancing is implemented automatically by dynamic routing
protocols. It is enabled with static routes when there are multiple static
routes to the same destination network using different next-hop routers.
Note: Only EIGRP supports unequal cost load balancing.
Load Balancing
Summary
• The primary functions of a router are to determine the best path to forward packets based
on the information in its routing table, and to forward packets toward their destination.
• The best path in the routing table is also known as the longest match. The longest match is
the route in the routing table that has the greatest number of far-left matching bits with
the destination IP address of the packet.
• Directly connected networks are networks that are configured on the active interfaces of a
router. A directly connected network is added to the routing table when an interface is
configured with an IP address and subnet mask (prefix length) and is active (up and up).
• Routers learn about remote networks in two ways: static routes and with dynamic routing
protocols.
• After a router determines the correct path, it can forward the packet on a directly
connected network, it can forward the packet to a next-hop router, or it can drop the
packet.
• Routers support three packet forwarding mechanisms: process switching, fast switching,
and CEF.
• There are several configuration and verification commands for routers, including show ip
route, show ip interface, show ip interface brief and show running-config.
Summary
• A routing table contains a list of routes known networks (prefixes and prefix lengths). The
source of this information is derived from directly connected networks, static routes, and
dynamic routing protocols.
• Every router makes its decision alone, based on the information it has in its own routing
table. The information in a routing table of one router does not necessarily match the
routing table of another router.
• Routing information about a path does not provide return routing information.
• Routing table entries include the route source, destination network, AD, metric, next-hop,
route timestamp, and exit interface.
• Static routes are manually configured and define an explicit path between two networking
devices.
• Dynamic routing protocols can discover a network, maintain routing tables, select a best
path, and automatically discover a new best path if the topology changes.
• The default route specifies a next-hop router to use when the routing table does not
contain a specific route that matches the destination IP address. A default route can be
either a static route or learned automatically from a dynamic routing protocol.
Summary
• IPv4 routing tables still have a structure based on classful addressing represented by levels
of indentation. IPv6 routing tables do not use the IPv4 routing table structure.
• Cisco IOS uses what is known as the administrative distance (AD) to determine the route
to install into the IP routing table. The AD represents the "trustworthiness" of the route.
The lower the AD, the more trustworthy the route source.
• Static routes are commonly used as a default route forwarding packets to a service
provider, for routes outside the routing domain and not learned by the dynamic routing
protocol, when the network administrator wants to explicitly define the path for a specific
network, or for routing between stub networks.
• Dynamic routing protocol are commonly used in networks consisting of more than just a
few routers, when a change in the network topology requires the network to
automatically determine another path, and for scalability. As the network grows, the
dynamic routing protocol automatically learns about any new networks.
• Current routing protocols include IGPs and EGPs. IGPs exchange routing information within
a routing domain administered by a single organization. The only EGP is BGP. BGP
exchanges routing information between different [Link] is used by ISPs to
route packets over the internet.
Summary
• Distance vector, link-state, and path vector routing protocols refer to the type of routing
algorithm used to determine best path.
• The main components of dynamic routing protocols are data structures, routing protocol
messages, and algorithms.
• The best path is selected by a routing protocol based on the value or metric it uses to
determine the distance to reach a network. The best path to a network is the path with
the lowest metric.
• When a router has two or more paths to a destination with equal cost metrics, then the
router forwards the packets using both paths equally. This is called equal cost load
balancing.
3.6 Static Routes
Types of Static Routes
Static routes are commonly implemented on a network. This is true even when there is
a dynamic routing protocol configured.
Static routes can be configured for IPv4 and IPv6. Both protocols support the following
types of static routes:
• Standard static route
• Default static route
• Floating static route
• Summary static route
Static routes are configured using the ip route and ipv6 route global configuration
commands.
Next-Hop Options
When configuring a static route, the next hop can be identified by an IP
address, exit interface, or both. How the destination is specified creates one
of the three following types of static route:
• Next-hop route - Only the next-hop IP address is specified
• Directly connected static route - Only the router exit interface is specified
• Fully specified static route - The next-hop IP address and exit interface are
specified
IPv4 Static Route Command
IPv4 static routes are configured using the following global configuration
command:
Router(config)# ip route network-address subnet-mask { ip-
address | exit-intf [ip-address]} [distance]
Note: Either the ip-address, exit-intf, or the ip-address and exit-
intf parameters must be configured.
IPv6 Static Route Command
IPv6 static routes are configured using the following global configuration
command:
Router(config)# ipv6 route ipv6-prefix/prefix-length {ipv6-
address | exit-intf [ipv6-address]} [distance]
Most of parameters are identical to the IPv4 version of the command.
Dual-Stack Topology
The figure shows a dual-stack network topology. Currently, no static routes are
configured for either IPv4 or IPv6.
IPv4 Starting Routing Tables
• Each router has entries only for directly connected networks and associated local
addresses.
• R1 can ping R2, but cannot ping the R3 LAN
R1# show ip route | begin Gateway
Gateway of last resort is not set
[Link]/16 is variably subnetted, 4 subnets, 2 masks
C [Link]/24 is directly connected, Serial0/1/0
L [Link]/32 is directly connected, Serial0/1/0
C [Link]/24 is directly connected, GigabitEthernet0/0/0
L [Link]/32 is directly connected, GigabitEthernet0/0/0
R1#
R1# ping [Link]
Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to [Link], timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5)
R1# ping [Link]
Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to [Link], timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
IPv6 Starting Routing Tables
• Each router has entries only for directly connected networks and associated local
addresses.
• R1 can ping R2, but cannot ping the R3 LAN.
R1# show ipv6 route | begin C
C 2001:DB8:ACAD:2::/64 [0/0]
via Serial0/1/0, directly connected
L 2001:DB8:ACAD:2::1/128 [0/0]
via Serial0/1/0, receive
C 2001:DB8:ACAD:3::/64 [0/0]
via GigabitEthernet0/0/0, directly connected
L 2001:DB8:ACAD:3::1/128 [0/0]
via GigabitEthernet0/0/0, receive
L FF00::/8 [0/0]
via Null0, receive
R1#
R1# ping 2001:db8:acad:2::2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2001:DB8:ACAD:2::2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/2/3 ms)
R1# ping 2001:DB8:cafe:2::1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2001:DB8:CAFE:2::1, timeout is 2 seconds:
% No valid route for destination
Success rate is 0 percent (0/1)
3.7 Configure IP Static Routes
IPv4 Next-Hop Static Route
In a next-hop static route, only the next-hop IP address is specified. The exit
interface is derived from the next hop. For example, three next-hop IPv4 static
routes are configured on R1 using the IP address of the next hop, R2.
R1(config)# ip route [Link] [Link] [Link]
R1(config)# ip route [Link] [Link] [Link]
R1(config)# ip route [Link] [Link] [Link]
The resulting routing table entries on R1:
IPv6 Next-Hop Static Route
The commands to configure R1 with the IPv6 static
routes to the three remote networks are as follows:
R1(config)# ipv6 unicast-routing
R1(config)# ipv6 route 2001:db8:acad:1::/64
2001:db8:acad:2::2
R1(config)# ipv6 route 2001:db8:cafe:1::/64
2001:db8:acad:2::2
R1(config)# ipv6 route 2001:db8:cafe:2::/64
2001:db8:acad:2::2
The routing table for R1 now has routes to the three
remote IPv6 networks.
IPv4 Directly Connected Static Route
When configuring a static route, another option is to use the exit interface to
specify the next-hop address. Three directly connected IPv4 static routes are
configured on R1 using the exit interface.
Note: Using a next-hop address is generally recommended. Directly connected static
routes should only be used with point-to-point serial interfaces.
R1(config)# ip route [Link] [Link] s0/1/0
R1(config)# ip route [Link] [Link] s0/1/0
R1(config)# ip route [Link] [Link] s0/1/0
IPv6 Directly Connected Static Route
In the example, three directly connected IPv6 static
routes are configured on R1 using the exit interface.
Note: Using a next-hop address is generally
recommended. Directly connected static routes
should only be used with point-to-point serial
interfaces.
R1(config)# ipv6 route 2001:db8:acad:1::/64 s0/1/0
R1(config)# ipv6 route 2001:db8:cafe:1::/64 s0/1/0
R1(config)# ipv6 route 2001:db8:cafe:2::/64 s0/1/0
IPv4 Fully Specified Static Route
• In a fully specified static route, both
the exit interface and the next-hop
IP address are specified. This form of
static route is used when the exit
interface is a multi-access interface
and it is necessary to explicitly
identify the next hop. The next hop
must be directly connected to the
specified exit interface. Using an exit
interface is optional, however it is
necessary to use a next-hop address.
• It is recommended that when the
exit interface is an Ethernet
network, that the static route
includes a next-hop address. You can
also use a fully specified static route
that includes both the exit interface
and the next-hop address.
IPv6 Fully Specified Static Route
In a fully specified static route, both the exit interface and the next-hop IPV6 address are
specified.
There is a situation in IPv6 when a fully specified static route must be used. If the IPv6
static route uses an IPv6 link-local address as the next-hop address, use a fully specified
static route. The figure shows an example of a fully specified IPv6 static route using an IPv6
link-local address as the next-hop address.
IPv6 Fully Specified Static Route (Cont.)
The reason a fully specified static route must be used is because IPv6 link-local
addresses are not contained in the IPv6 routing table. Link-local addresses are only
unique on a given link or network. The next-hop link-local address may be a valid
address on multiple networks connected to the router. Therefore, it is necessary that
the exit interface be included.
The following example shows the IPv6 routing table entry for this route. Notice that
both the next-hop link-local address and the exit interface are included.
Verify a Static Route
Along with show ip route, show ipv6 route, ping and traceroute, other useful
commands to verify static routes include the following:
• show ip route static
• show ip route network
• show running-config | section ip route
Replace ip with ipv6 for the IPv6 versions of the command.
3.8 Configure IP Default Static Routes
Default Static Route
• A default route is a static route that
matches all packets. A single default
route represents any network that is
not in the routing table.
• Routers commonly use default routes
that are either configured locally or
learned from another router. The
default route is used as the Gateway
of Last Resort.
• Default static routes are commonly
used when connecting an edge
router to a service provider network,
or a stub router (a router with only
one upstream neighbor router).
• The figure shows a typical default
static route scenario.
Default Static Route (Cont.)
IPv4 Default Static Route: The command syntax for an IPv4 default static route is similar to any
other IPv4 static route, except that the network address is [Link] and the subnet mask
is [Link]. The [Link] [Link] in the route will match any network address.
Note: An IPv4 default static route is commonly referred to as a quad-zero route.
The basic command syntax for an IPv4 default static route is as follows:
Router(config)# ip route [Link] [Link] {ip-address | exit-intf}
IPv6 Default Static Route: The command syntax for an IPv6 default static route is similar to any
other IPv6 static route, except that the ipv6-prefix/prefix-length is ::/0, which matches all
routes.
The basic command syntax for an IPv6 default static route is as follows:
Router(config)# ipv6 route ::/0 {ipv6-address | exit-intf}
Configure a Default Static Route
The example shows an IPv4 default static route configured on R1. With the
configuration shown in the example, any packets not matching more specific
route entries are forwarded to R2 at [Link].
R1(config)# ip route [Link] [Link] [Link]
An IPv6 default static route is configured in similar fashion. With this
configuration any packets not matching more specific IPv6 route entries are
forwarded to R2 at 2001:db8:acad:2::2
R1(config)# ipv6 route ::/0 2001:db8:acad:2::2
Verify a Default Static Route
The show ip route static command output from R1 displays the contents of the static routes in the
routing table. Note the asterisk (*) next to the route with code ‘S’. The asterisk indicates that this static
route is a candidate default route, which is why it is selected as the Gateway of Last Resort.
Notice that the static default route configuration uses the /0 mask for IPv4 default routes. Remember
that the IPv4 subnet mask in a routing table determines how many bits must match between the
destination IP address of the packet and the route in the routing table. A /0 mask indicates that none of
the bits are required to match. As long as a more specific match does not exist, the default static route
matches all packets.
Verify a Default Static Route (Cont.)
This example shows the show ipv6 route static command output to display the contents of the routing
table.
Notice that the static default route configuration uses the ::/0 prefix for IPv6 default routes. Remember
that the IPv6 prefix-length in a routing table determines how many bits must match between the
destination IP address of the packet and the route in the routing table. A ::/0 prefix indicates that none
of the bits are required to match. As long as a more specific match does not exist, the default static
route matches all packets.
3.9 Configure Floating Static Routes
Floating Static Routes
• Another type of static route is a floating static route. Floating static routes are static
routes that are used to provide a backup path to a primary static or dynamic route.
The floating static route is only used when the primary route is not available.
• To accomplish this, the floating static route is configured with a higher
administrative distance than the primary route. The administrative distance
represents the trustworthiness of a route. If multiple paths to the destination exist,
the router will choose the path with the lowest administrative distance.
• By default, static routes have an administrative distance of 1, making them
preferable to routes learned from dynamic routing protocols.
• The administrative distance of a static route can be increased to make the route
less desirable than that of another static route or a route learned through a
dynamic routing protocol. In this way, the static route “floats” and is not used when
the route with the better administrative distance is active.
Configure IPv4 and IPv6 Floating Static Routes
The commands to configure default and floating IP default routes are as follows:
R1(config)# ip route [Link] [Link] [Link]
R1(config)# ip route [Link] [Link] [Link] 5
R1(config)# ipv6 route ::/0 2001:db8:acad:2::2
R1(config)# ipv6 route ::/0 2001:db8:feed:10::2 5
The show ip route and show ipv6 route output verifies that the default routes to R2 are installed in
the routing table. Note that the IPv4 floating static route to R3 is not present in the routing table.
Test the Floating Static Routes
• What would happen if R2 failed?
To simulate this, R2 shuts down
both of its serial interfaces.
• R1 automatically generates syslog
messages for the link going down.
• A look at R1’s routing table would
show the secondary route being
used.
3.10 Configure Static Host Routes
Host Routes
A host route is an IPv4 address with a 32-bit mask, or an IPv6 address with a 128-bit
mask. The following shows the three ways a host route can be added to the routing
table:
• Automatically installed when an IP address is configured on the router
• Configured as a static host route
• Host route automatically obtained through other methods (discussed in later
courses)
Automatically Installed Host Routes
• Cisco IOS automatically installs a host route, also known as a local host route, when
an interface address is configured on the router. A host route allows for a more
efficient process for packets that are directed to the router itself, rather than for
packet forwarding.
• This is in addition to the connected route, designated with a C in the routing table
for the network address of the interface.
• The local routes are marked with L in the output of the routing table.
Static Host Routes
A host route can be a manually configured static route to direct traffic to a
specific destination device, such as the server shown in the figure. The static
route uses a destination IP address and a [Link] (/32) mask for IPv4
host routes, and a /128 prefix length for IPv6 host routes.
Configure Static Host Routes
The example shows the IPv4 and IPv6 static host route configuration on the
Branch router to access the server.
Branch(config)# ip route [Link] [Link] [Link]
Branch(config)# ipv6 route 2001:db8:acad:2::238/128 2001:db8:acad:1::2
Branch(config)# exit
Branch#
Verify Static Host Routes
A review of both the IPv4 and IPv6 route tables verifies that the routes are active.
Configure IPv6 Static Host Route with Link-Local Next-Hop
For IPv6 static routes, the next-hop address can be the link-local address of the
adjacent router. However, you must specify an interface type and an interface number
when using a link-local address as the next hop, as shown in the example. First, the
original IPv6 static host route is removed, then a fully specified route configured with
the IPv6 address of the server and the IPv6 link-local address of the ISP router.
Summary
• Static routes can be configured for IPv4 and IPv6. Both protocols support the following types of static
routes: standard static route, default static route, floating static route, and summary static route.
• When configuring a static route, the next hop can be identified by an IP address, exit interface, or
both. How the destination is specified creates one of the three following types of static route: next-
hop, directly connected, and fully specified.
• IPv4 static routes are configured using the following global configuration command: ip route network-
address subnet-mask { ip-address | exit-intf [ip=address] } [distance].
• IPv6 static routes are configured using the following global configuration command: ipv6 route ipv6-
prefix/prefix-length { ipv6-address | exit-intf [ipv6-address]} [distance].
• In a next-hop static route, only the next-hop IP address is specified. The exit interface is derived from
the next hop.
• When configuring a static route, another option is to use the exit interface to specify the next-hop
address. Directly connected static routes should only be used with point-to-point serial interfaces.
• In a fully specified static route, both the exit interface and the next-hop IP address are specified. This
form of static route is used when the exit interface is a multi-access interface and it is necessary to
explicitly identify the next hop. The next hop must be directly connected to the specified exit
interface.
• In a fully specified IPv6 static route, both the exit interface and the next-hop IPv6 address are
specified.
Summary
• A default route is a static route that matches all packets.
• Default static routes are commonly used when connecting an edge router to a service
provider network, and a stub router.
• The command syntax for an IPv4 default static route is similar to any other IPv4 static
route, except that the network address is [Link] and the subnet mask is [Link].
• The command syntax for an IPv6 default static route is similar to any other IPv6 static
route, except that the ipv6-prefix/prefix-length is ::/0, which matches all routes.
• Floating static routes are static routes that are used to provide a backup path to a primary
static or dynamic route in the event of a link failure.
• The floating static route is configured with a higher administrative distance than the
primary route. By default, static routes have an administrative distance of 1, making them
preferable to routes learned from dynamic routing protocols.
• IP floating static routes are configured by using the distance argument to specify an
administrative distance.
• A host route is an IPv4 address with a 32-bit mask or an IPv6 address with a 128-bit mask.
Summary
• There are three ways a host route can be added to the routing table: automatically
installed when an IP address is configured on the router, configured as a static host route,
or automatically obtained through other methods not covered in this module.
• Cisco IOS automatically installs a host route, also known as a local host route, when an
interface address is configured on the router.
• A host route can be a manually configured static route to direct traffic to a specific
destination device.
• For IPv6 static routes, the next-hop address can be the link-local address of the adjacent
router; however, you must specify an interface type and an interface number when using
a link-local address as the next hop. To do this, the original IPv6 static host route is
removed, then a fully specified route is configured with the IPv6 address of the server and
the IPv6 link-local address of the ISP router.
3.11 OSPF Features and Characteristics
Introduction to OSPF
• OSPF is a link-state routing protocol that was developed as an alternative
for the distance vector Routing Information Protocol (RIP). OSPF has
significant advantages over RIP in that it offers faster convergence and
scales to much larger network implementations.
• OSPF is a link-state routing protocol that uses the concept of areas. A
network administrator can divide the routing domain into distinct areas
that help control routing update traffic.
• A link is an interface on a router, a network segment that connects two
routers, or a stub network such as an Ethernet LAN that is connected to a
single router.
• Information about the state of a link is known as a link-state. All link-state
information includes the network prefix, prefix length, and cost.
• This module covers basic, single-area OSPF implementations and
configurations.
Components of OSPF
• All routing protocols share similar components. They all use routing
protocol messages to exchange route information. The messages help build
data structures, which are then processed using a routing algorithm.
• Routers running OSPF exchange messages to convey routing information
using five types of packets:
• Hello packet
• Database description packet
• Link-state request packet
• Link-state update packet
• Link-state acknowledgment packet
• These packets are used to discover neighboring routers and also to
exchange routing information to maintain accurate information about the
network.
Components of OSPF (Cont.)
OSPF messages are used to create and maintain three OSPF databases, as follows:
Database Table Description
•List of all neighbor routers to which a router has established bi-directional
Adjacency Neighbor communication.
Database Table •This table is unique for each router.
•Can be viewed using the show ip ospf neighbor command.
•Lists information about all other routers in the network.
Link-state
Topology •The database represents the network LSDB.
Database
Table •All routers within an area have identical LSDB.
(LSDB)
•Can be viewed using the show ip ospf database command.
•List of routes generated when an algorithm is run on the link-state
Forwardin database.
Routing
g •Each router's routing table is unique and contains information on how and
Table
Database where to send packets to other routers.
•Can be viewed using the show ip route command.
Components of OSPF (Cont.)
• The router builds the topology table using results of calculations based on the
Dijkstra shortest-path first (SPF) algorithm. The SPF algorithm is based on the
cumulative cost to reach a destination.
• The SPF algorithm creates an SPF tree by placing each router at the root of the tree
and calculating the shortest path to each node. The SPF tree is then used to
calculate the best routes. OSPF places the best routes into the forwarding
database, which is used to make the routing table.
Link-State Operation
To maintain routing information, OSPF routers complete a generic link-state
routing process to reach a state of convergence. The following are the link-
state routing steps that are completed by a router:
1. Establish Neighbor Adjacencies
2. Exchange Link-State Advertisements
3. Build the Link State Database
4. Execute the SPF Algorithm
5. Choose the Best Route
Single-Area and Multiarea OSPF
To make OSPF more efficient and scalable, OSPF supports hierarchical routing using
areas. An OSPF area is a group of routers that share the same link-state information in
their LSDBs. OSPF can be implemented in one of two ways, as follows:
• Single-Area OSPF - All routers are in one area. Best practice is to use area 0.
• Multiarea OSPF - OSPF is implemented using multiple areas, in a hierarchical
fashion. All areas must connect to the backbone area (area 0). Routers
interconnecting the areas are referred to as Area Border Routers (ABRs).
The focus of this module is on single-area OSPFv2.
Multiarea OSPF
• The hierarchical-topology design options with multiarea OSPF can offer the
following advantages.
• Smaller routing tables - Tables are smaller because there are fewer routing
table entries. This is because network addresses can be summarized
between areas. Route summarization is not enabled by default.
• Reduced link-state update overhead - Designing multiarea OSPF with
smaller areas minimizes processing and memory requirements.
• Reduced frequency of SPF calculations -– Multiarea OSPF localize the
impact of a topology change within an area. For instance, it minimizes
routing update impact because LSA flooding stops at the area boundary.
OSPFv3
• OSPFv3 is the OSPFv2 equivalent for exchanging IPv6 prefixes. OSPFv3
exchanges routing information to populate the IPv6 routing table with
remote prefixes.
• Note: With the OSPFv3 Address Families feature, OSPFv3 includes support
for both IPv4 and IPv6. OSPF Address Families is beyond the scope of this
curriculum.
• OSPFv3 has the same functionality as OSPFv2, but uses IPv6 as the
network layer transport, communicating with OSPFv3 peers and
advertising IPv6 routes. OSPFv3 also uses the SPF algorithm as the
computation engine to determine the best paths throughout the routing
domain.
• OSPFv3 has separate processes from its IPv4 counterpart. The processes
and operations are basically the same as in the IPv4 routing protocol, but
run independently.
3.12 OSPF Packets
Types of OSPF Packets
The table summarizes the five different types of Link State Packets (LSPs) used
by OSPFv2. OSPFv3 has similar packet types.
Type Packet Name Description
Discovers neighbors and builds adjacencies
1 Hello
between them
Checks for database synchronization between
2 Database Description (DBD)
routers
Requests specific link-state records from router to
3 Link-State Request (LSR)
router
4 Link-State Update (LSU) Sends specifically requested link-state records
Link-State Acknowledgment
5 Acknowledges the other packet types
(LSAck)
Link-State Updates
• LSUs are also used to forward
OSPF routing updates. An LSU
packet can contain 11 different
types of OSPFv2 LSAs. OSPFv3
renamed several of these LSAs
and also contains two additional
LSAs.
• LSU and LSA are often used
interchangeably, but the correct
hierarchy is LSU packets contain
LSA messages.
Hello Packet
The OSPF Type 1 packet is the
Hello packet. Hello packets are
used to do the following:
• Discover OSPF neighbors
and establish neighbor
adjacencies.
• Advertise parameters on
which two routers must
agree to become neighbors.
• Elect the Designated Router
(DR) and Backup
Designated Router (BDR) on
multiaccess networks like
Ethernet. Point-to-point
links do not require DR or
BDR.
3.13 OSPF Operation
OSPF Operational States
State Description
•No Hello packets received = Down.
Down State •Router sends Hello packets.
•Transition to Init state.
•Hello packets are received from the neighbor.
Init State •They contain the Router ID of the sending router.
•Transition to Two-Way state.
•In this state, communication between the two routers is
bidirectional.
Two-Way State
•On multiaccess links, the routers elect a DR and a BDR.
•Transition to ExStart state.
OSPF Operational States (Cont.)
State Description
On point-to-point networks, the two routers decide which
ExStart State router will initiate the DBD packet exchange and decide upon
the initial DBD packet sequence number.
•Routers exchange DBD packets.
Exchange
•If additional router information is required then transition to
State
Loading; otherwise, transition to the Full state.
•LSRs and LSUs are used to gain additional route information.
Loading State •Routes are processed using the SPF algorithm.
•Transition to the Full state.
Full State The link-state database of the router is fully synchronized.
Establish Neighbor Adjacencies
• To determine if there is an OSPF neighbor on the link, the router sends a
Hello packet that contains its router ID out all OSPF-enabled interfaces.
The Hello packet is sent to the reserved All OSPF Routers IPv4 multicast
address [Link]. Only OSPFv2 routers will process these packets.
• The OSPF router ID is used by the OSPF process to uniquely identify each
router in the OSPF area. A router ID is a 32-bit number formatted like an
IPv4 address and assigned to uniquely identify a router among OSPF peers.
• When a neighboring OSPF-enabled router receives a Hello packet with a
router ID that is not within its neighbor list, the receiving router attempts
to establish an adjacency with the initiating router.
Establish Neighbor Adjacencies (Cont.)
The process routers use to establish adjacency on a multiaccess network:
1 Down to Init State When OSPFv2 is enabled on the interface, R1 transitions from Down to Init
and starts sending OSPFv2 Hellos out of the interface in an attempt to
discover neighbors.
2 Init State When a R2 receives a hello from the previously unknown router R1, it adds
R1’s router ID to the neighbor list and responds with a Hello packet
containing its own router ID.
3 Two-Way State R1 receives R2’s hello and notices that the message contains the R1 router
ID in the list of R2’s neighbors. R1 adds R2’s router ID to the neighbor list
and transitions to the Two-Way State.
If R1 and R2 are connected with a point-to-point link, they transition to
ExStart
If R1 and R2 are connected over a common Ethernet network, the DR/BDR
election occurs.
4 Elect the DR & BDR The DR and BDR election occurs, where the router with the highest router ID
or highest priority is elected as the DR, and second highest is the BDR
Synchronizing OSPF Databases
After the Two-Way state, routers transition to database synchronization
states. This is a three step process, as follows:
• Decide first router: The router with the highest router ID sends its DBD
first.
• Exchange DBDs: As many as needed to convey the database. The other
router must acknowledge each DBD with an LSAck packet.
• Send an LSR: Each router compares the DBD information with the local
LSDB. If the DBD has more current link information, the router transitions
to the loading state.
After all LSRs have been exchanged and satisfied, the routers are considered
synchronized and in a full state. Updates (LSUs) are sent:
• When a change is perceived (incremental updates)
• Every 30 minutes
The Need for a DR
Multiaccess networks can create two
challenges for OSPF regarding the
flooding of LSAs, as follows:
• Creation of multiple adjacencies -
Ethernet networks could potentially
interconnect many OSPF routers over
a common link. Creating adjacencies
with every router would lead to an
excessive number of LSAs exchanged
between routers on the same
network.
• Extensive flooding of LSAs - Link-
state routers flood their LSAs any
time OSPF is initialized, or when
there is a change in the topology.
This flooding can become excessive.
LSA Flooding with a DR
• An increase in the number of routers on a multiaccess network also
increases the number of LSAs exchanged between the routers. This
flooding of LSAs significantly impacts the operation of OSPF.
• If every router in a multiaccess network had to flood and acknowledge all
received LSAs to all other routers on that same multiaccess network, the
network traffic would become quite chaotic.
• On multiaccess networks, OSPF elects a DR to be the collection and
distribution point for LSAs sent and received. A BDR is also elected in case
the DR fails. All other routers become DROTHERs. A DROTHER is a router
that is neither the DR nor the BDR.
• Note: The DR is only used for the dissemination of LSAs. The router will still use
the best next-hop router indicated in the routing table for the forwarding of all
other packets.
Summary
• Open Shortest Path First (OSPF) is a link-state routing protocol that was developed as an
alternative for the distance vector Routing Information Protocol (RIP).
• OSPF is a link-state routing protocol that uses the concept of areas for scalability.
• A link is an interface on a router. A link is also a network segment that connects two
routers, or a stub network such as an Ethernet LAN that is connected to a single router.
• All link-state information includes the network prefix, prefix length, and cost.
• All routing protocols use routing protocol messages to exchange route information. The
messages help build data structures, which are then processed using a routing algorithm.
• Routers running OSPF exchange messages to convey routing information using five types
of packets: the Hello packet, the database description packet, the link-state request
packet, the link-state update packet, and the link-state acknowledgment packet.
• OSPF messages are used to create and maintain three OSPF databases: the adjacency
database creates the neighbor table, the link-state database (LSDB) creates the topology
table, and the forwarding database creates the routing table.
• The router builds the topology table using results of calculations based on the Dijkstra SPF
(shortest-path first) algorithm. The SPF algorithm is based on the cumulative cost to reach
a destination. In OSPF, cost is used to determine the best path to the destination.
Summary
• To maintain routing information, OSPF routers complete a generic link-state routing
process to reach a state of convergence: Establish Neighbor Adjacencies, Exchange Link-
State Advertisements, Build the Link State Database, Execute the SPF Algorithm, Choose
the Best Route
• With single-area OSPF any number can be used for the area, best practice is to use area 0.
• Single-area OSPF is useful in smaller networks with few routers.
• With multiarea OSPF, one large routing domain can be divided into smaller areas, to
support hierarchical routing. Routing still occurs between the areas (interarea routing),
while many of the processor intensive routing operations, such as recalculating the
database, are kept within an area.
• OSPFv3 is the OSPFv2 equivalent for exchanging IPv6 prefixes. Recall that in IPv6, the
network address is referred to as the prefix and the subnet mask is called the prefix-
length.
• OSPF uses the following link-state packets (LSPs) to establish and maintain neighbor
adjacencies and exchange routing updates: 1 Hello, 2 DBD, 3 LSR, 4 LSU, and 5 LSAck.
• LSUs are also used to forward OSPF routing updates, such as link changes.
• Hello packets are used to: Discover OSPF neighbors and establish neighbor adjacencies,
Advertise parameters on which two routers must agree to become neighbors, and Elect
the Designated Router (DR) and Backup Designated Router (BDR) on multiaccess networks
like Ethernet. Point-to-point links do not require DR or BDR.
Summary
• Some important fields in the Hello packet are type, router ID, area ID, network mask, hello
interval, router priority, dead interval, DR, BDR and list of neighbors.
• The states that OSPF progresses through to do reach convergence are down state, init
state, two-way state, ExStart state, Exchange state, loading state, and full state.
• When OSPF is enabled on an interface, the router must determine if there is another OSPF
neighbor on the link by sending a Hello packet that contains its router ID out all OSPF-
enabled interfaces.
• The Hello packet is sent to the reserved All OSPF Routers IPv4 multicast address [Link].
Only OSPFv2 routers will process these packets.
• When a neighboring OSPF-enabled router receives a Hello packet with a router ID that is
not within its neighbor list, the receiving router attempts to establish an adjacency with
the initiating router.
• After the Two-Way state, routers transition to database synchronization states, which is a
three step process:
• Multiaccess networks can create two challenges for OSPF regarding the flooding of LSAs:
the creation of multiple adjacencies and extensive flooding of LSAs.
Summary
• A dramatic increase in the number of routers also dramatically increases the number of
LSAs exchanged between the routers.
• This flooding of LSAs significantly impact the operation of OSPF. If every router in a
multiaccess network had to flood and acknowledge all received LSAs to all other routers
on that same multiaccess network, the network traffic would become quite chaotic. This is
why DR and BDR election is necessary.
• On multiaccess networks, OSPF elects a DR to be the collection and distribution point for
LSAs sent and received. A BDR is also elected in case the DR fails.
3.14 OSPF Router ID
OSPF Reference Topology
The figure shows the topology
used for configuring OSPFv2 in this
module. The routers in the
topology have a starting
configuration, including interface
addresses. There is currently no
static routing or dynamic routing
configured on any of the routers.
All interfaces on R1, R2, and R3
(except the loopback 1 on R2) are
within the OSPF backbone area.
The ISP router is used as the
gateway to the internet of the
routing domain.
Router Configuration Mode for OSPF
OSPFv2 is enabled using the router ospf process-id global configuration mode
command. The process-id value represents a number between 1 and 65,535 and is
selected by the network administrator. The process-id value is locally significant. It is
considered best practice to use the same process-id on all OSPF routers.
R1(config)# router ospf 10
R1(config-router)# ?
area OSPF area parameters
auto-cost Calculate OSPF interface cost according to bandwidth
default-information Control distribution of default information
distance Define an administrative distance
exit Exit from routing protocol configuration mode
log-adjacency-changes Log changes in adjacency state
neighbor Specify a neighbor router
network Enable routing on an IP network
no Negate a command or set its defaults
passive-interface Suppress routing updates on an interface
redistribute Redistribute information from another routing protocol
router-id router-id for this OSPF process
R1(config-router)#
Router IDs
• An OSPF router ID is a 32-bit value, represented as an IPv4 address. It is used to
uniquely identify an OSPF router, and all OSPF packets include the router ID of the
originating router.
• Every router requires a router ID to participate in an OSPF domain. It can be
defined by an administrator or automatically assigned by the router. The router ID
is used by an OSPF-enabled router to do the following:
• Participate in the synchronization of OSPF databases – During the Exchange State, the
router with the highest router ID will send their database descriptor (DBD) packets first.
• Participate in the election of the designated router (DR) - In a multiaccess LAN environment,
the router with the highest router ID is elected the DR. The routing device with the second
highest router ID is elected the backup designated router (BDR).
Router ID Order of Precedence
Cisco routers derive the router ID
based on one of three criteria, in the
following preferential order:
1. The router ID is explicitly
configured using the OSPF router-
id rid router configuration mode
command. This is the
recommended method to assign a
router ID.
2. The router chooses the highest
IPv4 address of any of configured
loopback interfaces.
3. The router chooses the highest
active IPv4 address of any of its
physical interfaces.
Configure a Loopback Interface as the Router ID
Instead of relying on physical interface, the router ID can be assigned to a loopback
interface. Typically, the IPv4 address for this type of loopback interface should be
configured using a 32-bit subnet mask ([Link]). This effectively creates a host
route. A 32-bit host route would not get advertised as a route to other OSPF routers.
OSPF does not need to be enabled on an interface for that interface to be chosen as the
router ID.
Explicitly Configure a Router ID
In our reference topology the router ID for each router is assigned as follows:
• R1 uses router ID [Link]
• R2 uses router ID [Link]
• R3 uses router ID [Link]
Use the router-id rid router configuration mode command to manually assign
a router ID. In the example, the router ID [Link] is assigned to R1. Use
the show ip protocols command to verify the router ID.
R1(config)# router ospf 10
R1(config-router)# router-id [Link]
R1(config-router)# end
*May 23 19:33:42.689: %SYS-5-CONFIG_I: Configured from console by console
R1# show ip protocols | include Router ID
Router ID [Link]
R1#
Modify a Router ID
• After a router selects a router ID, an active OSPF router does not allow the router ID
to be changed until the router is reloaded or the OSPF process is reset.
• Clearing the OSPF process is the preferred method to reset the router ID.
R1# show ip protocols | include Router ID
Router ID [Link]
R1# conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)# router ospf 10
R1(config-router)# router-id [Link]
% OSPF: Reload or use "clear ip ospf process" command, for this to take effect
R1(config-router)# end
R1# clear ip ospf process
Reset ALL OSPF processes? [no]: y
*Jun 6 01:09:46.975: %OSPF-5-ADJCHG: Process 10, Nbr [Link] on GigabitEthernet0/0/1 from FULL to
DOWN, Neighbor Down: Interface down or detached
*Jun 6 01:09:46.981: %OSPF-5-ADJCHG: Process 10, Nbr [Link] on GigabitEthernet0/0/1 from LOADING
to FULL, Loading Done *
R1# show ip protocols | include Router ID
Router ID [Link]
R1#
3.15 Point-to-Point OSPF Networks
The network Command Syntax
• You can specify the interfaces that belong to a point-to-point network by
configuring the network command. You can also configure OSPF directly on the
interface with the ip ospf command.
• The basic syntax for the network command is as follows:
Router(config-router)# network network-address wildcard-mask area area-id
• The network-address wildcard-mask syntax is used to enable OSPF on interfaces.
Any interfaces on a router that match this part of the command are enabled to
send and receive OSPF packets.
• The area area-id syntax refers to the OSPF area. When configuring single-area
OSPFv2, the network command must be configured with the same area-id value
on all routers. Although any area ID can be used, it is good practice to use an area
ID of 0 with single-area OSPFv2. This convention makes it easier if the network is
later altered to support multiarea OSPFv2.
The Wildcard Mask
• The wildcard mask is typically the inverse of the subnet mask configured on that
interface.
• The easiest method for calculating a wildcard mask is to subtract the network
subnet mask from [Link], as shown for /24 and /26 subnet masks in the
figure.
Configure OSPF Using the network Command
Within routing configuration mode, there are two ways to identify the interfaces that
will participate in the OSPFv2 routing process.
• In the first example, the wildcard mask identifies the interface based on the
network addresses. Any active interface that is configured with an IPv4 address
belonging to that network will participate in the OSPFv2 routing process.
• Note: Some IOS versions allow the subnet mask to be entered instead of the
wildcard mask. The IOS then converts the subnet mask to the wildcard mask
format.
R1(config)# router ospf 10
R1(config-router)# network [Link] [Link] area 0
R1(config-router)# network [Link] [Link] area 0
R1(config-router)# network [Link] [Link] area 0
R1(config-router)#
Configure OSPF Using the network Command (Cont.)
• As an alternative, OSPFv2 can be enabled by specifying the exact interface IPv4
address using a quad zero wildcard mask. Entering network [Link] [Link] area 0 on
R1 tells the router to enable interface Gigabit Ethernet 0/0/0 for the routing process.
• The advantage of specifying the interface is that the wildcard mask calculation is not
necessary. Notice that in all cases, the area argument specifies area 0.
R1(config)# router ospf 10
R1(config-router)# network [Link] [Link] area 0
R1(config-router)# network [Link] [Link] area 0
R1(config-router)# network [Link] [Link] area 0
R1(config-router)#
Configure OSPF Using the ip ospf Command
To configure OSPF directly on the interface, use the ip ospf interface configuration
mode command. The syntax is as follows:
Router(config-if)# ip ospf process-id area area-id
Remove the network commands using the no form of the command. Then go to each
interface and configure the ip ospf command
R1(config)# router ospf 10
R1(config-router)# no network [Link] [Link] area 0
R1(config-router)# no network [Link] [Link] area 0
R1(config-router)# no network [Link] [Link] area 0
R1(config-router)# interface GigabitEthernet 0/0/0
R1(config-if)# ip ospf 10 area 0
R1(config-if)# interface GigabitEthernet 0/0/1
R1(config-if)# ip ospf 10 area 0
R1(config-if)# interface Loopback 0
R1(config-if)# ip ospf 10 area 0
R1(config-if)#
Passive Interface
By default, OSPF messages are forwarded out all OSPF-enabled interfaces. However,
these messages only need to be sent out interfaces that are connecting to other OSPF-
enabled routers.
Sending out unneeded messages on a LAN affects the network in three ways:
• Inefficient Use of Bandwidth - Available bandwidth is consumed transporting
unnecessary messages.
• Inefficient Use of Resources - All devices on the LAN must process and eventually
discard the message.
• Increased Security Risk - Without additional OSPF security configurations, OSPF
messages can be intercepted with packet sniffing software. Routing updates can be
modified and sent back to the router, corrupting the routing table with false metrics
that misdirect traffic.
Configure Passive Interfaces
• Use the passive-interface router
configuration mode command to
prevent the transmission of routing
messages through a router
interface, but still allow that
network to be advertised to other
routers.
• The show ip protocols command is
then used to verify that the
interface is listed as passive.
OSPF Point-to-Point Networks
By default, Cisco routers elect a DR and BDR on Ethernet interfaces, even if there is
only one other device on the link. You can verify this with the show ip ospf
interface command. The DR/ BDR election process is unnecessary as there can only be
two routers on the point-to-point network between R1 and R2. Notice in the output
that the router has designated the network type as BROADCAST.
R1# show ip ospf interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 is up, line protocol is up
Internet Address [Link]/30, Area 0, Attached via Interface Enable
Process ID 10, Router ID [Link], Network Type BROADCAST, Cost: 1
Topology-MTID Cost Disabled Shutdown Topology Name
0 1 no no Base
Enabled by interface config, including secondary ip addresses
Transmit Delay is 1 sec, State BDR, Priority 1
Designated Router (ID) [Link], Interface address [Link]
Backup Designated router (ID) [Link], Interface address [Link]
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
OSPF Point-to-Point Networks (Cont.)
To change this to a point-to-point network, use the interface configuration
command ip ospf network point-to-point on all interfaces where you want to disable
the DR/BDR election process.
R1(config)# interface GigabitEthernet 0/0/0
R1(config-if)# ip ospf network point-to-point
*Jun 6 00:44:05.208: %OSPF-5-ADJCHG: Process 10, Nbr [Link] on GigabitEthernet0/0/0 from
FULL to DOWN, Neighbor Down: Interface down or detached
*Jun 6 00:44:05.211: %OSPF-5-ADJCHG: Process 10, Nbr [Link] on GigabitEthernet0/0/0 from
LOADING to FULL, Loading Done
R1(config-if)# end
R1# show ip ospf interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 is up, line protocol is up
Internet Address [Link]/30, Area 0, Attached via Interface Enable
Process ID 10, Router ID [Link], Network Type POINT_TO_POINT, Cost: 1
Topology-MTID Cost Disabled Shutdown Topology Name
Loopbacks and Point-to-Point Networks
• Use loopbacks to provide additional interfaces for a variety of purposes. By default,
loopback interfaces are advertised as /32 host routes.
• To simulate a real LAN, the loopback interface can be configured as a point-to-point
network to advertise the full network.
• What R2 sees when R1 advertises the loopback interface as-is:
R2# show ip route | include 10.10.1
O [Link]/32 [110/2] via [Link], 00:03:05, GigabitEthernet0/0/0
• Configuration change at R1:
R1(config-if)# interface Loopback 0
R1(config-if)# ip ospf network point-to-point
• Result at R2:
R2# show ip route | include 10.10.1
O [Link]/24 [110/2] via [Link], 00:03:05, GigabitEthernet0/0/0
3.15 Multiaccess OSPF Networks
OPSF Network Types
Another type of network that uses OSPF is
the multiaccess OSPF network. Multiaccess
OSPF networks are unique in that one
router controls the distribution of LSAs.
The router that is elected for this role
should be determined by the network
administrator through proper configuration.
OPSF Designated Router
• In multiaccess networks, OSPF elects a DR and BDR. The DR is responsible for
collecting and distributing LSAs sent and received. The DR uses the multicast IPv4
address [Link] which is meant for all OSPF routers.
• A BDR is also elected in case the DR fails. The BDR listens passively and maintains a
relationship with all the routers. If the DR stops producing Hello packets, the BDR
promotes itself and assumes the role of DR.
• All other routers become a DROTHER (a router that is neither the DR nor the BDR).
DROTHERs use the multiaccess address [Link] (all designated routers) to send
OSPF packets to the DR and BDR. Only the DR and BDR listen for [Link].
OPSF Multiaccess Reference Topology
• In the multiaccess topology shown
in the figure, there are three
routers interconnected over a
common Ethernet multiaccess
network, [Link]/24.
• Because the routers are connected
over a common multiaccess
network, OSPF has automatically
elected a DR and BDR. R3 has
been elected as the DR because its
router ID is [Link], which is the
highest in this network. R2 is the
BDR because it has the second
highest router ID in the network.
Verify OSPF Router Roles
To verify the roles of the OSPFv2 router, use the show ip ospf interface command.
The output generated by R1 confirms that the following:
• R1 is not the DR or BDR, but is a DROTHER with a default priority of 1. (Line 7)
• The DR is R3 with router ID [Link] at IPv4 address [Link], while the BDR is R2 with router
ID [Link] at IPv4 address [Link]. (Lines 8 and 9)
• R1 has two adjacencies: one with the BDR and one with the DR. (Lines 20-22)
R1# show ip ospf interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 is up, line protocol is up
Internet Address [Link]/24, Area 0, Attached via Interface Enable
Process ID 10, Router ID [Link], Network Type BROADCAST, Cost: 1
(output omitted)
Transmit Delay is 1 sec, State DROTHER, Priority 1
Designated Router (ID) [Link], Interface address [Link]
Backup Designated router (ID) [Link], Interface address [Link]
(output omitted)
Neighbor Count is 2, Adjacent neighbor count is 2
Adjacent with neighbor [Link] (Backup Designated Router)
Adjacent with neighbor [Link] (Designated Router)
Suppress hello for 0 neighbor(s)
R1#
Verify OSPF Router Roles (Cont.)
The output generated by R2 confirms that:
• R2 is the BDR with a default priority of 1. (Line 7)
• The DR is R3 with router ID [Link] at IPv4 address [Link], while the BDR is R2 with router ID
[Link] at IPv4 address [Link]. (Lines 8 and 9)
• R2 has two adjacencies; one with a neighbor with router ID [Link] (R1) and the other with the DR.
(Lines 20-22)
R2# show ip ospf interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 is up, line protocol is up
Internet Address [Link]/24, Area 0, Attached via Interface Enable
Process ID 10, Router ID [Link], Network Type BROADCAST, Cost: 1
(output omitted)
Transmit Delay is 1 sec, State BDR, Priority 1
Designated Router (ID) [Link], Interface address [Link]
Backup Designated Router (ID) [Link], Interface address [Link]
(output omitted)
Neighbor Count is 2, Adjacent neighbor count is 2
Adjacent with neighbor [Link]
Adjacent with neighbor [Link] (Designated Router)
Suppress hello for 0 neighbor(s)
R2#
Verify OSPF Router Roles (Cont.)
The output generated by R3 confirms that:
• R3 is the DR with a default priority of 1. (Line 7)
• The DR is R3 with router ID [Link] at IPv4 address [Link], while the BDR is R2 with router ID
[Link] at IPv4 address [Link]. (Lines 8 and 9)
• R3 has two adjacencies: one with a neighbor with router ID [Link] (R1) and the other with the BDR.
(Lines 20-22)
R3# show ip ospf interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 is up, line protocol is up
Internet Address [Link]/24, Area 0, Attached via Interface Enable
Process ID 10, Router ID [Link], Network Type BROADCAST, Cost: 1
(output omitted)
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) [Link], Interface address [Link]
Backup Designated Router (ID) [Link], Interface address [Link]
(output omitted)
Neighbor Count is 2, Adjacent neighbor count is 2
Adjacent with neighbor [Link]
Adjacent with neighbor [Link] (Backup Designated Router)
Suppress hello for 0 neighbor(s)
R3#
Verify DR/BDR Adjacencies
To verify the OSPFv2 adjacencies, use the show ip ospf neighbor command.
The state of neighbors in multiaccess networks can be as follows:
• FULL/DROTHER - This is a DR or BDR router that is fully adjacent with a non-DR or
BDR router. These two neighbors can exchange Hello packets, updates, queries,
replies, and acknowledgments.
• FULL/DR - The router is fully adjacent with the indicated DR neighbor. These two
neighbors can exchange Hello packets, updates, queries, replies, and
acknowledgments.
• FULL/BDR - The router is fully adjacent with the indicated BDR neighbor. These two
neighbors can exchange Hello packets, updates, queries, replies, and
acknowledgments.
• 2-WAY/DROTHER - The non-DR or BDR router has a neighbor relationship with
another non-DR or BDR router. These two neighbors exchange Hello packets.
The normal state for an OSPF router is usually FULL. If a router is stuck in
another state, it is an indication that there are problems in forming
adjacencies. The only exception to this is the 2-WAY state, which is normal in a
multiaccess broadcast network.
Verify DR/BDR Adjacencies (Cont.)
The output generated by R2 confirms that R2 has adjacencies with the following
routers:
• R1 with router ID [Link] is in a Full state and R1 is neither the DR nor BDR.
• R3 with router ID [Link] is in a Full state and the role of R3 is DR.
R2# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
[Link] 1 FULL/DROTHER 00:00:31 [Link] GigabitEthernet0/0/0
[Link] 1 FULL/DR 00:00:34 [Link] GigabitEthernet0/0/0 R2#
Default DR/BDR Election Process
The OSPF DR and BDR election is based on the following criteria, in sequential order:
1. The routers in the network elect the router with the highest interface priority as
the DR. The router with the second highest interface priority is becomes the BDR.
• The priority can be configured to be any number between 0 – 255.
• If the interface priority value is set to 0, that interface cannot be elected as DR nor BDR.
• The default priority of multiaccess broadcast interfaces is 1.
2. If the interface priorities are equal, then the router with the highest router ID is
elected the DR. The router with the second highest router ID is the BDR.
• The election process takes place when the first router with an OSPF-enabled
interface is active on the network. If all of the routers on the network have not
finished booting, it is possible that a router with a lower router ID becomes the DR.
• The addition of a new router does not initiate a new election process.
DR Failure and Recovery
After the DR is elected, it remains the DR until one of the following events occurs:
• The DR fails.
• The OSPF process on the DR fails or is stopped.
• The multiaccess interface on the DR fails or is shutdown.
If the DR fails, the BDR is automatically promoted to DR. This is the case even if
another DROTHER with a higher priority or router ID is added to the network after the
initial DR/BDR election. However, after a BDR is promoted to DR, a new BDR election
occurs and the DROTHER with the highest priority or router ID is elected as the new
BDR.
The ip ospf priority Command
• If the interface priorities are equal on all routers, the router with the highest router
ID is elected the DR.
• Instead of relying on the router ID, it is better to control the election by setting
interface priorities. This also allows a router to be the DR in one network and a
DROTHER in another.
• To set the priority of an interface, use the command ip ospf priority value, where
value is 0 to 255.
• A value of 0 does not become a DR or a BDR.
• A value of 1 to 255 on the interface makes it more likely that the router becomes the DR or
the BDR.
Configure OSPF Priority
The example shows the commands being used to change the R1 G0/0/0 interface
priority from 1 to 255 and then reset the OSPF process.
R1(config)# interface GigabitEthernet 0/0/0
R1(config-if)# ip ospf priority 255
R1(config-if)# end
R1# clear ip ospf process
Reset ALL OSPF processes? [no]: y
R1# *Jun 5 03:47:41.563: %OSPF-5-ADJCHG: Process 10, Nbr [Link] on GigabitEthernet0/0/0
from FULL to DOWN, Neighbor Down: Interface down or detached
3.16 Modify Single-Area OSPFv2
Cisco OSPF Cost Metric
• Routing protocols use a metric to determine the best path of a packet across a
network. OSPF uses cost as a metric. A lower cost indicates a better path.
• The Cisco cost of an interface is inversely proportional to the bandwidth of the
interface. Therefore, a higher bandwidth indicates a lower cost. The formula used
to calculate the OSPF cost is:
Cost = reference bandwidth / interface bandwidth
• The default reference bandwidth is 108 (100,000,000); therefore, the formula is:
Cost = 100,000,000 bps / interface bandwidth in bps
• Because the OSPF cost value must be an integer, FastEthernet, Gigabit Ethernet,
and 10 GigE interfaces share the same cost. To correct this situation, you can:
• Adjust the reference bandwidth with the auto-cost reference-bandwidth command on each
OSPF router.
• Manually set the OSPF cost value with the ip ospf cost command on necessary interfaces.
Cisco OSPF Cost Metric (Cont.)
Refer to the table for a breakdown of the cost calculation
Adjust the Reference Bandwidth
• The cost value must be an integer. If something less than an integer is calculated,
OSPF rounds up to the nearest integer. Therefore, the OSPF cost assigned to a
Gigabit Ethernet interface with the default reference bandwidth of 100,000,000
bps would equal 1, because the nearest integer for 0.1 is 0 instead of 1.
Cost = 100,000,000 bps / 1,000,000,000 = 1
• For this reason, all interfaces faster than Fast Ethernet will have the same cost
value of 1 as a Fast Ethernet interface.
• To assist OSPF in making the correct path determination, the reference bandwidth
must be changed to a higher value to accommodate networks with links faster than
100 Mbps.
Adjust the Reference Bandwidth (Cont.)
• Changing the reference bandwidth does not actually affect the bandwidth capacity
on the link; rather, it simply affects the calculation used to determine the metric.
• To adjust the reference bandwidth, use the auto-cost reference-bandwidth Mbps
router configuration command.
• This command must be configured on every router in the OSPF domain.
• Notice in the command that the value is expressed in Mbps; therefore, to adjust the costs for
Gigabit Ethernet, use the command auto-cost reference-bandwidth 1000. For 10 Gigabit
Ethernet, use the command auto-cost reference-bandwidth 10000.
• To return to the default reference bandwidth, use the auto-cost reference-bandwidth 100
command.
• Another option is to change the cost on one specific interface using the ip ospf cost
cost command.
Adjust the Reference Bandwidth (Cont.)
• Whichever method is used, it is important to apply the configuration to all routers
in the OSPF routing domain.
• The table shows the OSPF cost if the reference bandwidth is adjusted to
accommodate 10 Gigabit Ethernet links. The reference bandwidth should be
adjusted anytime there are links faster than FastEthernet (100 Mbps).
• Use the show ip ospf interface command to verify the current OSPFv2 cost assigned
to the interface.
OSPF Accumulates Cost
• The cost of an OSPF route is
the accumulated value from
one router to the destination
network.
• Assuming the auto-cost
reference-bandwidth 10000
command has been
configured on all three
routers, the cost of the links
between each router is now
10. The loopback interfaces
have a default cost of 1.
OSPF Accumulates Cost (Cont.)
• You can calculate the cost for
each router to reach each
network.
• For example, the total cost
for R1 to reach the
[Link]/24 network is 11.
This is because the link to R2
cost = 10 and the loopback
default cost = 1. 10 + 1 = 11.
• You can verify this with the
show ip route command.
OSPF Accumulates Cost (Cont.)
Verifying the accumulated cost for the path to the [Link]/24 network:
R1# show ip route | include [Link]
O [Link]/24 [110/11] via [Link], 01:05:02, GigabitEthernet0/0/0
R1# show ip route [Link]
Routing entry for [Link]/24
Known via "ospf 10", distance 110, metric 11, type intra area
Last update from [Link] on GigabitEthernet0/0/0, 01:05:13 ago
Routing Descriptor Blocks:
* [Link], from [Link], 01:05:13 ago, via GigabitEthernet0/0/0
Route metric is 11, traffic share count is 1
R1#
Manually Set OSPF Cost Value
Reasons to manually set the cost value include:
• The Administrator may want to influence path selection within OSPF, causing different paths
to be selected than what normally would given default costs and cost accumulation.
• Connections to equipment from other vendors who use a different formula to calculate OSPF
cost.
To change the cost value reported by the local OSPF router to other OSPF routers, use
the interface configuration command ip ospf cost value.
R1(config)# interface g0/0/1 R1(config-if)# ip ospf cost 30
R1(config-if)# interface lo0 R1(config-if)# ip ospf cost 10
R1(config-if)# end
R1#
Test Failover to Backup Route
What happens if the link between R1 and R2 goes down? You can simulate that by
shutting down the Gigabit Ethernet 0/0/0 interface and verifying the routing table is
updated to use R3 as the next-hop router. Notice that R1 can now reach the
[Link]/30 network through R3 with a cost value of 50.
R1# show ip route ospf | begin 10
[Link]/8 is variably subnetted, 8 subnets, 3 masks
O [Link]/30 [110/50] via [Link], 00:00:14, GigabitEthernet0/0/1
O [Link]/30 [110/40] via [Link], 00:00:14, GigabitEthernet0/0/1
O [Link]/24 [110/50] via [Link], 00:00:14, GigabitEthernet0/0/1
O [Link]/24 [110/40] via [Link], 00:00:14, GigabitEthernet0/0/1
R1#
Hello Packet Intervals
• OSPFv2 Hello packets are transmitted to multicast address [Link] (all OSPF
routers) every 10 seconds. This is the default timer value on multiaccess and point-
to-point networks.
Note: Hello packets are not sent on interfaces set to passive by the passive-interface command.
• The Dead interval is the period that the router waits to receive a Hello packet
before declaring the neighbor down. If the Dead interval expires before the routers
receive a Hello packet, OSPF removes that neighbor from its link-state database
(LSDB). The router floods the LSDB with information about the down neighbor out
all OSPF-enabled interfaces. Cisco uses a default of 4 times the Hello interval. This
is 40 seconds on multiaccess and point-to-point networks.
Verify Hello and Dead Intervals
• The OSPF Hello and Dead intervals are configurable on a per-interface basis.
• The OSPF intervals must match or a neighbor adjacency does not occur.
• To verify the currently configured OSPFv2 interface intervals, use the show ip ospf
interface command. The Gigabit Ethernet 0/0/0 Hello and Dead intervals are set to
the default 10 seconds and 40 seconds respectively.
R1# show ip ospf interface g0/0/0
GigabitEthernet0/0/0 is up, line protocol is up
Internet Address [Link]/30, Area 0, Attached via Interface Enable
Process ID 10, Router ID [Link], Network Type POINT_TO_POINT, Cost: 10
Topology-MTID Cost Disabled Shutdown Topology Name
0 10 no no Base
Enabled by interface config, including secondary ip addresses
Transmit Delay is 1 sec, State POINT_TO_POINT
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
(output omitted)
Verify Hello and Dead Intervals (Cont.)
Use the show ip ospf neighbor command to see the Dead Time counting down from
40 seconds. By default, this value is refreshed every 10 seconds when R1 receives a
Hello from the neighbor.
R1# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
[Link] 0 FULL/ - 00:00:35 [Link] GigabitEthernet0/0/1
[Link] 0 FULL/ - 00:00:31 [Link] GigabitEthernet0/0/0
R1#
Modify OSPFv2 Intervals
• It may be desirable to change the OSPF timers so that routers detect network
failures in less time. Doing this increases traffic, but sometimes the need for quick
convergence is more important than the extra traffic it creates.
Note: The default Hello and Dead intervals are based on best practices and should only be
altered in rare situations.
• OSPFv2 Hello and Dead intervals can be modified manually using the following
interface configuration mode commands:
Router(config-if)# ip ospf hello-interval seconds
Router(config-if)# ip ospf dead-interval seconds
• Use the no ip ospf hello-interval and no ip ospf dead-interval commands to reset
the intervals to their default.
Modify OSPFv2 Intervals (Cont.)
• In the example, the Hello interval for the link between R1 and R2 is changed to 5
seconds. The Cisco IOS automatically modifies the Dead interval to four times the
Hello interval. However, you can document the new Dead interval in the
configuration by manually setting it to 20 seconds, as shown.
• When the Dead Timer on R1 expires, R1 and R2 lose adjacency. R1 and R2 must be
configured with the same Hello interval. Use the show ip ospf neighbor command
on R1 to verify the neighbor adjacencies.
R1(config)# interface g0/0/0
R1(config-if)# ip ospf hello-interval 5
R1(config-if)# ip ospf dead-interval 20
R1(config-if)#
*Jun 7 04:56:07.571: %OSPF-5-ADJCHG: Process 10, Nbr [Link] on GigabitEthernet0/0/0
from FULL to DOWN, Neighbor Down: Dead timer expired
R1(config-if)# end
R1# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
[Link] 0 FULL/ - 00:00:37 [Link] GigabitEthernet0/0/1
R1#
3.17 Default Route Propagation
Propagate a Default Static Route in OSPFv2
To propagate a default route, the edge router must be configured with the following:
• A default static route using the ip route [Link] [Link] [next-hop-address | exit-intf]
command.
• The default-information originate router configuration command. This instructs R2 to be the
source of the default route information and propagate the default static route in OSPF
updates.
In the example, R2 is configured with a loopback to simulate a connection to the
internet. A default route is configured and propagated to all other OSPF routers in the
routing domain.
Note: When configuring static routes, best practice is to use the next-hop IP address. However, when
simulating a connection to the internet, there is no next-hop IP address. Therefore, we use the exit-intf
argument.
R2(config)# interface lo1
R2(config-if)# ip address [Link] [Link]
R2(config-if)# exit
R2(config)# ip route [Link] [Link] loopback 1
%Default route without gateway, if not a point-to-point interface, may impact performance
R2(config)# router ospf 10
R2(config-router)# default-information originate
R2(config-router)# end
R2#
Verify the Propagated Default Route
• You can verify the default route settings on R2 using the show ip route command.
You can also verify that R1 and R3 received a default route.
• Notice that the route source on R1 is O*E2, signifying that it was learned using
OSPFv2. The asterisk identifies this as a good candidate for the default route. The
E2 designation identifies that it is an external route. The meaning of E1 and E2 is
beyond the scope of this module.
R2# show ip route | begin Gateway
Gateway of last resort is [Link] to network [Link]
S* [Link]/0 is directly connected, Loopback1
[Link]/8 is variably subnetted, 9 subnets, 3 masks
(output omitted)
R1# show ip route | begin Gateway
Gateway of last resort is [Link] to network [Link]
O*E2 [Link]/0 [110/1] via [Link], 00:11:08, GigabitEthernet0/0/0
[Link]/8 is variably subnetted, 9 subnets, 3 masks
(output omitted)
3.18 Verify Single-Area OSPFv2
Verify OSPF Neighbors
After configuring single-area OSPFv2, you will need to verify your configurations. The
following two commands are particularly useful for verifying routing:
• show ip interface brief - This verifies that the desired interfaces are active with correct IP
addressing.
• show ip route- This verifies that the routing table contains all the expected routes.
Additional commands for determining that OSPF is operating as expected include the
following:
• show ip ospf neighbor
• show ip protocols
• show ip ospf
• show ip ospf interface
Verify OSPF Neighbors (Cont.)
• Use the show ip ospf neighbor command to verify that the router has formed an
adjacency with its neighboring routers. If the router ID of the neighboring router is
not displayed, or if it does not show as being in a state of FULL, the two routers
have not formed an OSPFv2 adjacency.
Note: A non-DR or BDR router that has a neighbor relationship with another non-DR or BDR
router will display a two-way adjacency instead of full.
• The following command output displays the neighbor table of R1.
R1# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
[Link] 0 FULL/ - 00:00:35 [Link] GigabitEthernet0/0/1
[Link] 0 FULL/ - 00:00:31 [Link] GigabitEthernet0/0/0
R1#
Verify OSPF Neighbors (Cont.)
Two routers may not form an OSPFv2 adjacency if the following occurs:
• The subnet masks do not match, causing the routers to be on separate networks.
• The OSPFv2 Hello or Dead Timers do not match.
• The OSPFv2 Network Types do not match.
• There is a missing or incorrect OSPFv2 network command.
Verify OSPF Protocol Settings
The show ip protocols R1# show ip protocols
command is a quick way to *** IP Routing is NSF aware ***
verify vital OSPF (output omitted)
Routing Protocol is "ospf 10"
configuration information, Outgoing update filter list for all interfaces is not set
as shown in the command Incoming update filter list for all interfaces is not set
Router ID [Link]
output. This includes the Number of areas in this router is 1. 1 normal 0 stub 0 nssa
OSPFv2 process ID, the Maximum path: 4
Routing for Networks:
router ID, interfaces Routing on Interfaces Configured Explicitly (Area 0):
explicitly configured to Loopback0
GigabitEthernet0/0/1
advertise OSPF routes, the GigabitEthernet0/0/0
neighbors the router is Routing Information Sources:
Gateway Distance Last Update
receiving updates from, [Link] 110 00:09:30
and the default [Link] 110 00:09:58
Distance: (default is 110)
administrative distance, R1#
which is 110 for OSPF.
Verify OSPF Process Information
The show ip ospf R1# show ip ospf
command can also Routing Process "ospf 10" with ID [Link]
Start time: 00:01:47.390, Time elapsed: 00:12:32.320
be used to examine (output omitted)
the OSPFv2 process Cisco NSF helper support enabled
Reference bandwidth unit is 10000 mbps
ID and router ID, as Area BACKBONE(0)
shown in the Number of interfaces in this area is 3
Area has no authentication
command output. SPF algorithm last executed 00:11:31.231 ago
This command SPF algorithm executed 4 times
Area ranges are
displays the OSPFv2 Number of LSA 3. Checksum Sum 0x00E77E
area information and Number of opaque link LSA 0. Checksum Sum 0x000000
Number of DCbitless LSA 0 Number of indication LSA 0
the last time the SPF Number of DoNotAge LSA 0 Flood list length 0
algorithm was R1#
executed.
Verify OSPF Interface Settings
The show ip ospf interface command provides a detailed list for every OSPFv2-enabled
interface. Specify an interface to display the settings of just that interface. This
command shows the process ID, the local router ID, the type of network, OSPF cost, DR
and BDR information on multiaccess links (not shown), and adjacent neighbors.
R1# show ip ospf interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 is up, line protocol is up
Internet Address [Link]/30, Area 0, Attached via Interface Enable
Process ID 10, Router ID [Link], Network Type POINT_TO_POINT, Cost: 10
<output omitted>
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor [Link]
Suppress hello for 0 neighbor(s)
R1#
Verify OSPF Interface Settings (Cont.)
To get a quick summary of OSPFv2-enabled interfaces, use the show ip ospf interface
brief command, as shown in the command output. This command is useful for seeing
important information including:
• Interfaces are participating in OSPF
• Networks that are being advertised (IP Address/Mask)
• Cost of each link
• Network state
• Number of neighbors on each link
R1# show ip ospf interface brief
Interface PID Area IP Address/Mask Cost State Nbrs F/C
Lo0 10 0 [Link]/24 10 P2P 0/0
Gi0/0/1 10 0 [Link]/30 30 P2P 1/1
Gi0/0/0 10 0 [Link]/30 10 P2P 1/1
R1#
Summary
• OSPFv2 is enabled using the router ospf process-id global configuration mode command.
The process-id value represents a number between 1 and 65,535 and is selected by the
network administrator.
• An OSPF router ID is a 32-bit value, represented as an IPv4 address. The router ID is used
by an OSPF-enabled router to synchronize OSPF databases and participate in the election
of the DR and BDR.
• Cisco routers derive the router ID based on one of three criteria, in this order: 1) Router ID
is explicitly configured using the OSPF router-id rid router configuration mode command,
2) the router chooses the highest IPv4 address of any of configured loopback interfaces or
3) the router chooses the highest active IPv4 address of any of its physical interfaces.
• The basic syntax for the network command is network network-address wildcard-mask
area area-id. Any interfaces on a router that match the network address in the network
command can send and receive OSPF packets.
• When configuring single-area OSPFv2, the network command must be configured with
the same area-id value on all routers. The wildcard mask is typically the inverse of the
subnet mask configured on that interface, but could also be a quad zero wildcard mask,
which would specify the exact interface.
Summary
• To configure OSPF directly on the interface, use the ip ospf interface configuration mode
command. The syntax is ip ospf process-id area area-id.
• Use the passive-interface router configuration mode command to stop transmitting
routing messages through a router interface, but still allow that network to be advertised
to other routers.
• The DR/ BDR election process is unnecessary as there can only be two routers on the
point-to-point network between R1 and R2. Use the interface configuration command ip
ospf network point-to-point on all interfaces where you want to disable the DR/BDR
election process.
• By default, loopback interfaces are advertised as /32 host routes. To simulate a real LAN,
the Loopback 0 interface is configured as a point-to-point network.
• OSPF Network Types
• The DR is responsible for collecting and distributing LSAs . The DR uses the multicast IPv4
address [Link] which is meant for all OSPF routers. If the DR stops producing Hello
packets, the BDR promotes itself and assumes the role of DR. All other routers become a
DROTHER.
• DROTHERs use the multiaccess address [Link] (all designated routers) to send OSPF
packets to the DR and BDR. Only the DR and BDR listen for [Link].
• To verify the roles of the OSPFv2 router, use the show ip ospf interface command.
Summary
• To verify the OSPFv2 adjacencies, use the show ip ospf neighbor command. The state of
neighbors in multiaccess networks can be: FULL/DROTHER, FULL/DR. FULL/BDR, or 2-
WAY/DROTHER.
• The OSPF DR and BDR election decision is based on the router with the highest interface
priority as the DR. The router with the second highest interface priority is elected as the
BDR. If the interface priorities are equal, then the router with the highest router ID is
elected the DR. The router with the second highest router ID is the BDR.
• The interface priority can be configured to be any number between 0 – 255. If the
interface priority value is set to 0, that interface cannot be elected as DR nor BDR. The
default priority of multiaccess broadcast interfaces is 1.
• OSPF DR and BDR elections are not pre-emptive. If the DR fails, the BDR is automatically
promoted to DR.
• To set the priority of an interface, use the command ip ospf priority value, where value is
0 to 255. If the value is 0, the router will not become a DR or BDR. If the value is 1 to 255,
then the router with the higher priority value will more likely become the DR or BDR on
the interface.
• OSPF uses cost as a metric. A lower cost indicates a better path than a higher cost.
• The formula used to calculate the OSPF cost is: Cost = reference bandwidth / interface
bandwidth.
Summary
• Because the OSPF cost value must be an integer, FastEthernet, Gigabit Ethernet, and 10
GigE interfaces share the same cost. To correct this situation, you can adjust the reference
bandwidth with the auto-cost reference-bandwidth command on each OSPF router, or
manually set the OSPF cost value with the ip ospf cost command.
• The cost of an OSPF route is the accumulated value from one router to the destination
network. OSPF cost values can be manipulated to influence the route chosen by OSPF. To
change the cost value report by the local OSPF router to other OSPF routers, use the
interface configuration command ip ospf cost value.
• If the Dead interval expires before the routers receive a Hello packet, OSPF removes that
neighbor from its link-state database (LSDB). The router floods the LSDB with information
about the down neighbor out all OSPF-enabled interfaces.
• Cisco uses a default of 4 times the Hello interval or 40 seconds on multiaccess and point-
to-point networks. To verify the OSPFv2 interface intervals, use the show ip ospf interface
command.
• OSPFv2 Hello and Dead intervals can be modified manually using the following interface
configuration mode commands: ip ospf hello-interval and ip ospf dead-interval.
Summary
• In OSPF terminology, the router located between an OSPF routing domain and a non-OSPF
network is called the ASBR. To propagate a default route, the ASBR must be configured
with a default static route using the ip route [Link] [Link] [next-hop-address | exit-intf]
command, and the default-information originate router configuration command.
• Verify the default route settings on the ASBR using the show ip route command.
• Additional commands for determining that OSPF is operating as expected include: show ip
ospf neighbor, show ip protocols, show ip ospf, and show ip ospf interface.
• Use the show ip ospf neighbor command to verify that the router has formed an
adjacency with its neighboring routers.