[Link].
com
Dynamic Routing
There are various routing protocols that are designed to exchange route
information with neighbors. The most popular currently include OSPF and
EIGRP. The network administrator does not configure dynamic routes. They
are learned so that each router installs and selects routes for best path
selection. The distinction between each routing protocol is how they learn,
update and advertise routes between neighbors.
OSPFv2 Routing Protocol
OSPF is a link-state routing protocol that builds and maintains a global
topology database. That is accomplished with the exchange of link-state
advertisements (LSA) between OSPF routers. Topology and routing
information is communicated to OSPF neighbors in LSAs. There are event-
triggered updates that are sent only when a link failure occurs to conserve
bandwidth.
OSPF Characteristics
Link-state routing protocol
Metric = link cost (bandwidth)
Global view database topology table
Shortest path to destination calculated
Event-triggered routing updates
Auto-summary disabled (default)
Scalable to large enterprise domains
Fast convergence when there is link failure
Load balancing across four equal paths
OSPF is characterized by well-defined hierarchical layers that enable route
summarization and smaller routing tables per router. The routing updates
are minimized when there are link failures enabling faster convergence. In
addition routing issues such as flapping and routing loops are limited to an
OSPF area.
There is a mandatory common backbone area 0 only for multi-area OSPF.
All other areas must connect to the OSPF backbone area. That is required
to advertise routes between areas. OSPFv2 refers to the version of OSPF
that only supports IPv4 addressing on network interfaces. It is the most
widely deployed version of OSPF for dynamic routing. The area number for
single-area OSPF does not have to be numbered area 0.
[Link]
OSPF is an IP-only routing protocol that is well suited to current intranet
and internet connectivity. Consider as well that internet and cloud-based
services are IP-only connections. Single-area OSPF design reduces the
routing tables and number of LSAs advertised between routers. All areas
must be connected directly to the backbone.
OSPF Neighbor Adjacency
The purpose of OSPF hello packets are to discover neighbors and establish
neighbor adjacency. Hello packets are also sent to maintain neighbor
relationships and confirm that a neighbor is still active. OSPF routers
establish adjacency with all connected neighbors for bidirectional
communication. That enables all routers to synchronize database and
routing tables.
Adjacency States
The following describe the sequence of OSPF states required to establish
neighbor adjacency and exchange routing tables.
1. Down - No hello packets have been received from neighbor/s.
2. Attempt - NBMA routers only. Hello packet has not been received from
NBMA neighbor. Hello packet is sent to neighbor.
3. Init - Hello packet is received from neighbor without the router ID listed.
There are settings such as timers verified to match.
4. Two-Way - Hello packets sent between neighbor with router ID of local
router. Neighbor adjacency is established and DR/BDR election occurs
based on highest router ID.
5. Exstart - OSPF elected DR router starts exchanging LSAs with
neighbors. The router with highest router ID remains DR unless priority
was modified to influence selected router.
6. Exchange - Routers exchange database descriptor packets (DBD) and
manage database synchronization to neighbor/s.
7. Loading - Routers complete exchange of all link-state advertisements
(LSA) between neighbors.
8. Full - This is normal state where adjacency is established between
OSPF neighbors and tables are updated for convergence.
[Link]
There is a hello timer configured to send hello packets at fixed intervals.
All timers must match between directly connected neighbor interfaces.
OSPF neighbor adjacency is not formed when there is a mismatch of hello
or dead timers. The following describe additional reasons why neighbor
adjacency would not occur between neighbors.
Subnet mismatch
Network type mismatch
Timers mismatch
MTU mismatch
Area ID mismatch
Metric Calculation
Each routing protocol has a unique method for calculating route metric
(cost). OSPF calculates cost based on interface bandwidth. The default cost
of an OSPF enabled interface = 1 (100 Mbps / 100 Mbps).
cost = 100 Mbps / interface bandwidth
Each link is comprised of the local interface and a neighbor interface. The
lowest cost assignable to a link is 1 even though calculation could arrive at a
lower number. The reference bandwidth of OSPF is configurable to account
for faster Ethernet interfaces that start at Gigabit (1000 Mbps) speed today.
The reference bandwidth is a global configuration command that must
match for all routers in the same OSPF routing domain.
router ospf 1
auto-cost reference-bandwidth 1000
The alternative to reference bandwidth method is ip ospf cost command. It
allows you to configure the cost directly on a network interface. The third
option is to manually configure interface speed with the IOS interface
bandwidth command. That would affect how OSPF calculates metric for
that specific link. You would have to configure the bandwidth command on
both local and neighbor interfaces.
OSPF Hello Packets
The hello packet is used to establish neighbor adjacencies and maintain
neighbor relationships. It also detects the operational status of neighbors.
and notifies when a link failure occurs. OSPF routes advertised from a
neighbor with an interface that is down are deleted from the routing table.
The following configuration settings are advertised in each OSPF hello
packet to all connected neighbors.
[Link]
Hello and dead timer
Router priority
DR/BDR assigned
Area assigned to neighbor interface
Subnet mask of neighbor interface
OSPF Authentication method
OSPF network type
OSPF Router ID
OSPF routers must be assigned a router ID that is a unique identifier to all
connected OSPF neighbors. The router ID is advertised in routing updates
to identify where updates originated. Cisco default OSPF configuration has
no router ID assigned. The following commands configure a router ID from
router configuration mode.
router ospf 1
router-id [Link]
OSPF Router ID Selection
1. Unique 32-bit IPv4 dotted-decimal address.
2. Purpose is to identify each router for routing updates and adjacency.
3. Manually configured router ID is preferred first.
4. The highest IP address on a loopback interface is assigned when no
router ID is configured.
5. The highest IP address of any active physical interface is assigned if no
loopback interface exists.
[Link]
Example: Router ID
Refer to the network topology drawing and determine what router ID is
assigned for router-1?
Figure 1 Router ID Configuration
There is no manually configured router ID on router-1. Based on OSPF
rules, the highest loopback interface address configured is assigned as
router ID. The router is borrowing the IP address only and does not affect
loopback interface operation.
Table 1 OSPF Packet Types
Packet Type Description
Hello neighbor discovery, adjacency, and status
Database Descriptor send database table update to neighbor
Link-State Request LSA request for updates sent to neighbors
Link-State Update flooding LSA (route) updates to neighbors
Link-State ACK acknowledge LSA update from neighbor
[Link]
OSPF Designated Router
OSPF designated router (DR) advertises routing updates to all connected
spokes on a shared (broadcast) network. The most common example of a
broadcast network type is Ethernet. OSPF DR minimizes routing updates
between OSPF neighbors on a broadcast network. It is a hub router that
advertises routing updates via [Link] multicast address. Consider that a
network broadcast segment refers to a common subnet or VLAN.
Designated Router (DR) Election
1. Router default OSPF priority = 1
2. Router with highest configured OSPF priority is elected DR
3. Router with highest router ID address is elected DR when priorities are
equal. First preference is an explicitly configured router ID.
4. When no router ID is explicitly configured, the highest loopback address
is assigned as router ID for a router. DR election then compares that
router ID with neighbors for DR election.
5. Router assigns the highest physical interface address as router ID for
OSPF when no loopback interface exists. DR election then compares
that router ID with neighbors for DR election.
6. Router with second highest priority is elected BDR.
7. Router with second highest router ID is elected BDR.
All OSPF routers send routing updates via [Link] multicast address to
DR and BDR routers. The Cisco OSPF priority setting on a default router
configuration has a value of 1. That is assigned to an OSPF enabled
interface. The router priority is configurable to influence DR election.
Backup Designated Router
OSPF elects Backup Designated Router (BDR) on each broadcast domain.
The purpose of BDR is to provide failover or redundancy to the elected DR.
All routing updates from connected non-DR and non-BDR routers called
spokes, are sent to the DR. The same routing updates are also sent to the
elected BDR. The difference is that BDR never sends updates to spoke
routers. That is only done from the elected DR as shown with Figure 3-19.
Anytime there is a DR failure, then BDR is automatically assigned as DR for
that subnet or VLAN.
[Link]
Figure 2 OSPF DR/BDR Operation
Table 2 OSPF Neighbor States
Neighbor State Adjacency DR Relationship Description
Full/DR FULL Neighbor is DR Neighbor_ID
Full/BDR FULL Neighbor is BDR Neighbor_ID
Full/DROTHER FULL none broadcast spoke
2-WAY/DROTHER 2-WAY none broadcast spoke
router-1# show ip ospf neighbor
Neighbor_ID Pri State Dead Time Address Interface
[Link] 1 Full/DR 00:00:12 [Link] Gig0/0
The results of show ip ospf neighbor command displays operational status
information. The State column displays DR relationship with neighbor. For
example, Full/DR indicates that the local router has full adjacency with
[Link] neighbor. That neighbor is elected DR for the broadcast domain.
DROTHER indicates there is no exchange of routing updates between
spoke neighbors. That is characteristic of a broadcast network where
updates are only sent between DR and spoke routers .
[Link]
Neighbor Field Descriptions
Neighbor_ID = Neighbor router ID
Pri = Neighbor priority
State = Neighbor adjacency + DR relationship
Dead Time = Dead timer age
Address = IP address of neighbor interface
Interface = Ethernet interface of neighbor
Example: Designated Router
Refer to the network drawing. All routers are configured with the default
OSPF priority (1). What router will be elected as designated router (DR)?
Figure 3 OSPF Designated Router Election
Answer
Ethernet interfaces within an OSPF broadcast domain are assigned to the
same VLAN. There is a default configuration with the same priority on each
router. The router with highest configured router ID (RID) is elected as DR
for all routers connected to switch-1.
[Link]
The elected DR is Router-4 with [Link] configured as router ID.
Router-3 has second highest configured router ID [Link] and elected
Backup DR (BDR). The highest IP address is calculated from left to right.
The numbers for each IP address match until octet 3 where subnet 4 is
higher. That is the IP address assigned to Router-4.
[Link]
[Link]
[Link]
[Link] = Router-4
Example: DR Priority
Refer to the network topology drawing. What router is elected DR based on
the configuration?
Figure 4 Designated Router Priority
The router with highest configured priority is elected as Designated Router
from a broadcast domain. In this example, router-2 is elected DR with
priority 100. Configuring priority setting influences the election of a specific
router as DR/BDR. The router with second highest priority is elected as
Backup Designated Router for the broadcast domain. In this example,
router-1 is elected BDR with priority 10. OSPF enabled router with a priority
of zero (0) cannot be elected as DR or BDR. The following command
assigns a priority of zero (0) to an OSPF interface.
router(config-if)# ip ospf priority 0
[Link]
OSPF Network Type
You can enable OSPF globally or per interface, however both methods will
enable OSPF routing on an interface. All dynamic routing protocols are
based on interfaces as opposed to the physical device.
OSPF router interfaces all connect to an area. They also exchange routing
updates with all directly connected OSPF neighbors. There are some
exceptions where a configuration is per routing domain such as reference
bandwidth.
OSPF network types are configured automatically based on the network
interface media. For example, OSPF automatically assigns Broadcast
network type to an Ethernet interface. There are serial interfaces as well that
are assigned Point-to-Point network type. It is not a shared broadcast link as
with an Ethernet segment. The OSPF serial interfaces connect only to a
single neighbor.
Example: Network Type
Refer to the network topology drawing. What OSPF network type is
assigned to the OSPF interfaces?
Figure 5 OSPF Network Type
[Link]
OSPF automatically assigns network type based on the interface media. In
this example, OSPF interfaces are connected to an Ethernet switch. The
network type assigned is Broadcast. Ethernet is a multi-access broadcast
network where multiple routers are assigned to a broadcast domain. The
purpose of a VLAN is to create a Layer 2 broadcast domain on a network
switch. OSPF automatically elects DR/BDR routers on a broadcast network
to send routing updates.
Example: Network Type
Refer to the network topology drawing. What OSPF network type is
assigned to the OSPF interfaces?
Figure 6 OSPF Network Type
OSPF automatically assigns serial interfaces as point-to-point network type.
There is no DR/BDR elected on a point-to-point network type. Each router
advertises routing updates to the neighbor directly. In fact, there is a
separate broadcast domain for each link on the same subnet. OSPF only
advertises routing updates to neighbors within a common subnet. OSPF
neighbors directly connected with Ethernet interfaces are manually
configured as Point-to-Point network type. That is a common practice since
OSPF will automatically configure Broadcast network type.
[Link]
OSPF Operation
OSPF is based on a hierarchical network topology where there is a
backbone area. Any new area must be connected to the backbone area
or have a virtual transit link through a connected area.
Single-Area OSPF has only a single area where all routers are connected
with at least one network interface.
The OSPF process ID is a unique number assigned to an OSPF routing
instance. It is only locally significant to the router. Multiple process ID can
be assigned per interface.
The valid range for a process ID is 1-65535. There is a separate OSPF
database topology table per process ID.
Cisco supports multiple OSPF instances per router defined with a
process ID. There is a maximum of 32 processes permitted per router.
All OSPF routers send hello packets to neighbors on the same segment
(subnet) using multicast [Link] destination IP address.
Hello timer interval for broadcast and point-to-point network type is 10
seconds. The default dead timer is 4 hello intervals (40 seconds).
There is no maximum hop count for OSPF so it is unlimited.
OSPF router ID is manually configured or default to highest loopback IP
address.
Passive interfaces prevent router from sending hello messages to
neighbors. There is no adjacency formed or routing updates sent.
OSPF load balances up to four equal cost paths as a default. There is no
support for unequal cost path load balancing.
Path metric is cumulative and calculated based on interface cost
(bandwidth). The default administrative distance is 110.
There is a designated router election for broadcast network type. The
router with highest router ID is elected for a default configuration.
SPF algorithm calculates best path to each destination and loops are
prevented with topology database.
[Link]
OSPF Configuration
OSPF is a classless routing protocol and wildcard masks are required to
define subnets for route advertisements. OSPF network area command
enables OSPF routing on all local interfaces that are assigned an address
within the subnet range specified. The routes are advertised to the area
assigned and all neighbor/s assigned to that area.
For example, an interface assigned [Link] is enabled for OSPF when
network area command is configured with [Link]/16 or
[Link]/24 network address. The subnet (route) is then advertised to
the area assigned. OSPF supports either 32-bit dotted-decimal number or
the equivalent decimal number to an area. The assignable range is from
[Link] - [Link] or decimal equivalent of 0 to 255,255,255,255.
OSPF can be enabled directly on an interface as well. For example,
assigning interface Fa0/1 to OSPF process 1 and area 0 would require
interface command ip ospf 1 area 0. The result is OSPF will advertise the
subnet assigned to that local interface to OSPF neighbors. It takes
precedence as well when a subnet from the network area command is
within the same range of an interface subnet address.
Example: OSPF Configuration
The following example will advertise [Link]/24 subnet from any local
interface assigned within that same subnet to all connected OSPF
neighbors in area 0.
network [Link] [Link] area 0
OSPFv2 single-area global configuration that is advertising subnet
[Link]/16 to area 0 and [Link]/24 to area 0.
router ospf 1
router-id [Link]
network [Link] [Link] area 0
network [Link] [Link] area 0
Default-Information Originate
The purpose of default-information originate is to advertise a default route to
connected OSPF neighbors. There is a single route configured under a
dynamic routing protocol. The traditional default route is configured locally
on a router and used as a gateway of last resort. It is deployed as a backup
to a primary link.
[Link]
Table 3 OSPF Operational Commands
IOS Command Description
Display all link states for areas where router
show ip ospf database
has an interface and advertising routers
Display all neighbors that have adjacency
show ip ospf neighbors
with local router and DR
Display operational state of OSPF enabled
show ip ospf interface
interface, timers. process ID and router ID
IOS command show ip ospf database displays the database topology
table. It is a global table comprised of all OSPF link-states for an OSPF
domain. The local database table is exchanged between all OSPF
neighbors. It creates a network topology used to calculate best path
(shortest) to a destination.
The network topology and path cost for each link is considered as part of the
calculation. The routing table is updated with the destination subnet and
preferred next hop address.
Wildcard Masks
An often overlooked topic on the CCNA exam is wildcard masks. The
wildcard mask is a technique for matching specific IP address or range of IP
addresses. It is used by OSPF routing protocol to advertise routes to
neighbors. In addition access control lists (ACL) filter based on the IP
address range configured from a wildcard mask. The wildcard mask of
[Link] translates to any network address that can be advertised.
As a result all/any network addresses assigned to an IP address are
advertised to area 0.
The wildcard mask is an inverted mask where the matching IP address or
range is based on zero (0) bits. The additional bits are set to 1 as no match
required. The wildcard [Link] is used to match a single IP address. The
wildcard mask for [Link] is [Link] (invert the bits so zero=1 and
one=0) noted with the following example.
11111111.11111111.111 00000.00000000 = subnet mask
00000000.00000000.000 11111.11111111 = wildcard mask
[Link]
Example 1: Classful Wildcard
The following wildcard [Link] will only match on the [Link] subnet
and not match on everything else. This could be used to define a single
subnet to advertise from OSPF.
192 . 168 . 3 . 0
11000000.10101000.00000011.00000000
00000000.00000000.00000000.11111111 = [Link]
[Link] [Link] = match on [Link] subnet only
Example 2: Classless Wildcard
The classless wildcard can filter based on any network boundary. The
following wildcard mask [Link] matches on all of the addresses for
[Link]/30 subnet only. It is equivalent to the [Link] subnet
mask. There is network address ([Link]) and broadcast address
([Link]) for that subnet that are not host assignable.
10 . 10 . 1 . 0
00001010.00001010.00000001.000000 00
00000000.00000000.00000000.000000 11 = [Link]
[Link] [Link] = match [Link] and [Link]
Question 1
Configure OSPF wildcard mask to advertise only [Link] subnet to
neighbor (zeros mask off subnet)
network [Link] [Link] area 0
Question 2
Configure OSPF wildcard mask to advertise only [Link] subnet for
advertising to neighbor (zeros mask off subnet)
network [Link] [Link] area 0
Question 3
Configure OSPF wildcard mask to advertise all [Link] subnets for
advertising to neighbor (zeros mask off subnet)
network [Link] [Link] area 0
[Link]
Example 1: OSPF Wildcard Mask
Refer to the network topology drawing. What subnets are advertised
between router-1 and router-2 based on the configuration? How does the
current configuration affect OSPF normal operations?
Figure 7 Wildcard Mask Example 1
Router-1
This is OSPF global configuration instead of per interface. In this example
the first network command advertises all [Link]/16 subnets from
router-1 to area 0. Subnet connecting router-1 and router-2 ([Link]/24)
is called a connected route. It is automatically added to the routing table.
Remember that network interfaces advertise OSPF routes. The subnet
assigned to router-1 interface Gi1/0 must be included in the subnet range of
network command. The wildcard mask is used to configure subnet range.
The interface address [Link]/24 (Gi1/0) of router-1 is within that range.
In fact, any network interface that starts with 192.168.x.x is enabled for
OSPF. OSPF wont establish adjacency to router-2 unless Gi1/1 interface
address is included.
The second network command advertises only [Link]/24 subnet from
router-1 to area 0. If router-2 is connected to area 0, then by extension
router-2 receives routes from router-1. The wildcard mask is the reverse of
a subnet mask. For example, [Link] = [Link] (/24).
[Link]
Figure 8 Router-1 OSPF Routes
Router-2
This is OSPF global configuration instead of per interface as well. In this
example, the first network command advertises all [Link]/16 subnets
from router-2 to area 0.
The subnet connecting router-1 and router-2 ([Link]/24) is called a
connected route. It is automatically added to the routing table. The subnet
assigned to router-2 interface Gi1/0 must be included in the subnet range of
network command. The interface address [Link]/24 (Gi1/0) of router-2
is within that range. The second network command advertises only
[Link]/24 subnet from router-2 to area 0. If router-1 is connected to
area 0, then by extension router-1 receives routes from router-2.
Figure 9 Router-2 OSPF Routes
Example 2: OSPF Wildcard Mask
Refer to the network topology drawing. What subnets are advertised
between router-1 and router-2 based on the configuration? How does the
current configuration affect OSPF normal operations?
[Link]
Figure 10 Wildcard Mask Example 2
Router-1
This is OSPF global configuration instead of per interface. The first network
command enables only [Link]/24 subnet based on the wildcard mask.
That prevents OSPF from advertising [Link]/24 subnet since it is out
of range. The second network command enables OSPF on all interfaces
configured with [Link]/16 as a subnet. Any network interface that starts
with 172.16.x.x will be enabled for OSPF.
Figure 11 Router-1 OSPF Routes
Router-2
This is OSPF global configuration instead of per interface. The first network
command enables all [Link]/8 subnets based on the wildcard mask. Any
network interface that starts with 192.x.x.x will be enabled for OSPF routing.
As a result, interface [Link]/24 (Gi1/0) on router-2 is enabled for
OSPF. That interface will advertise [Link]/24 and [Link]/24
subnets to area 0. The second network command only enables
[Link]/24 subnet from router-2 to area 0.
[Link]
Figure 12 Router-2 OSPF Routes
Example 3: OSPF Wildcard Mask
Refer to the network topology drawing. What subnets are advertised
between router-1 and router-2 based on the configuration?
Figure 13 Wildcard Mask Example 3
Router-1
This OSPF configuration is both global and per interface. The network
command enables only [Link]/24 subnet based on the wildcard mask.
The interface commands enable OSPF directly on router-1 interface Gi1/0.
OSPF will advertise [Link]/24 subnet to area 0 for process ID 1. There
is no global configuration or interface configuration for [Link] subnet.
That subnet is not enabled for OSPF or advertised to area 0.
[Link]
Figure 14 Router-1 OSPF Routes
Router-2
This OSPF configuration is both global and per interface. The network
command enables only [Link]/24 subnet based on the wildcard mask.
The interface commands enable OSPF directly on router-2 interface Gi1/0.
OSPF will advertise [Link]/24 subnet to area 0 for process ID 1. There
is no global configuration or interface configuration for [Link] subnet.
That subnet is not enabled for OSPF or advertised to area 0.
Figure 15 Router-2 OSPF Routes
Example 4: OSPF Wildcard Mask
Refer to the network topology drawing. What wildcard mask will enable
advertising of all connected routes via OSPF from router-1 to router-3?
Answer
The OSPF network area command specifies a subnet/s for an OSPF
process and area. Any router interface assigned an IP address within that
range is included in the OSPF process. There is support for multiple OSPF
process numbers per router. Each OSPF process ID is assigned a number
and becomes a separate OSPF instance.
[Link]
Figure 16 Wildcard Mask Example 4
The network area command enables [Link]/30 - [Link]/30
subnet range. Interface serial0/0 ([Link]/30) on router-1 is within that
subnet range and enabled for OSPF.
router-1(config)# router ospf 1
router-1(config-router)# network [Link] [Link] area 0
172 . 16 . 1 .16 17-31
00000000.00000000.00000000.0000 1111
0 . 0 . 0 . 15
The wildcard mask zeros match on the first 3 octets (172.16.1) of the
network address. The 15 causes a match on the leftmost 4 bits of the 4th
octet. In addition it masks (1s) off the rightmost 4 bits of the 4th octet. It does
the opposite of what a subnet mask does.
[Link]
Example 5: OSPF Metric
Refer to the network topology drawing. All routers are enabled with OSPF
and have default settings. What path/s will the router select to forward
packets from router-1 to router-5?
Answer
OSPF selects a path based on interface cost (bandwidth) from source to
destination. The cost of each link is calculated and added for a cumulative
metric (path cost). The minimum cost assignable to any link is 1. The default
OSPF reference bandwidth is 100 Mbps.
Figure 17 OSPF Metric
The following formula is used to calculate OSPF interface cost:
interface cost = 100 Mbps / interface bandwidth
OSPF default metric costs
10 Mbps = 10
100 Mbps = 1
200 Mbps = 1
1000 Mbps = 1
[Link]
Example: 25 Mbps
Cost = 100 Mbps / 25 Mbps = 4
Path 1: Router-1 Router-4 Router-5 = 4+1 = 5
Path 2: Router-1 Router-2 Router-4 Router-5 = 1+1+1 = 3
Path 3: Router-1 Router-3 Router-4 Router-5 = 1+1+1 = 3
There are two equal lowest cost (highest bandwidth) paths to Router-5.
The cost for Path 2 and Path 3 is 3. OSPF will load balance packets across
each path as a result. There is no support for unequal-cost load balancing of
OSPF routes.
Example: OSPF Timers
What is the OSPF hello timer setting on router-1 with a Cisco default
configuration?
Figure 18 OSPF Hello Timer
The default OSPF hello timer interval for a point-to-point network type is 10
seconds. The dead timer is a default of 4 times the hello interval. Ethernet is
an example of a broadcast network type that has the same timer settings.