OSPF
OSPF
Open Shortest Path First (OSPF) is an Interior Gateway>Link State Routing Protocol. It uses "Cost" as the metric, which is automatically derived from interface bandwidth by default
- You can manually configure the costs of links if you want to manipulate the path, but it usually takes the best path anyway
- Uses Dijkstra's Shortest Path First algorithm to determine the best path to learned networks
- Cost is calculated by Reference bandwidth / Interface bandwidth
- Default reference bandwidth is 100Mbps
5 OSPF network types (2 main, 3 odd)
- 2 Main
- Broadcast
- Enabled on Ethernet and FDDI links by default
- Routers elect DR/BDR to reduce overhead
- Default Hello interval is 10 seconds, default dead time 40 seconds
- Point-to-Point
- Broadcast
- 3 Odd (non-broadcast networks, like Frame Relay, X.25, and ATM (Asynchronous Transfer Mode)
- Non-broadcast multi-access (NBMA)
- Emulates a broadcast network (DR/BDR elections)
- Every router must be configured with the IP address of its neighbors
- Creates Permanent Virtual Circuits (PVCs) to be configured between endpoints
- Default Hello interval is 30 seconds
- Point-to-multipoint
- Emulates a point-to-point network
- Organizes PVCs into a collection of P2p networks
- Hello packets are replicated and transmitted individually to each neighbor
- Default Hello is 30 seconds
- Emulates a point-to-point network
- Point-to-multipoint (non-broadcast)
non-broadcastcan be appended to P2m networks to force unicast packets instead of multicast packets- Default Hello is 30 seconds
- Non-broadcast multi-access (NBMA)
OSPF Process
- Discover neighbors
- Hello Packets
- When OSPF enabled, a router will send out and listen for Hello packets to form adjacencies with other OSPF routers
- Hello Packets
- Form Adjacencies
- Flood Link State Database (LSDB)
- First sends DBD (DataBase Description)
- Adjacent routers will tell each other their known networks
- If a router is missing a route, it will send a Link State Request (LSR)
- The supplying router will respond with a Link State Update (LSU), which contains one or more Link State Advertisements (LSA)
- After receiving an LSU, the receiver will send an LSAck (Link State Acknowledgement) back to the sender
- If the sender doesn't receive an LSAck, it will resend the LSU
- First sends DBD (DataBase Description)
- Compute Shortest Path
- Install best routes to routing table
- Respond to network changes
OSPF Areas and Route Types
- Areas
- Areas are logical groupings of networks, routers, and links
- They create a hierarchical and more efficient routing domain
- Single-area networks do not need to be in Area 0
- Backbone Area (Area 0)
- The "Transit area", or the backbone
- All other areas must connect to Area 0
- In a multi-area network, it typically does not contain users
- The "Transit area", or the backbone
- Non-backbone Area (areas 1+)
- Also called "standard" areas, connect users to Transit area
- Stub Area
- Doesn't receive external routes (routes from other autonomous systems)
- Receive the default route and Inter-Area routes
- Totally Stubby Area
- Doesn't receive External LSAs or Inter-Area routes
- Only receives the default route injection from the ABR
- Not-So-Stubby-Area (NSSA)
- Similar to Stub Areas, but they can import external routes as Type-7 LSAs
- Areas are logical groupings of networks, routers, and links
- Intra-Area Routes (O)
- Routes within the same OSPF area
- Inter-Area Routes (O IA)
- Routes to other OSPF areas, but within the same Autonomous System (AS)
- External Routes
- Routes that are injected into OSPF using redistribution from outside of the AS
- The default External Route is Type 2 External Routes (O E2)
- Two types of External routes:
- Type 1 External Routes (O E1)
- Cost of these routes are the sum of the internal (router to ASBR) and external (ASBR to destination) costs
- Type 2 External Routes (O E2)
- Just the external cost (ASBR to destination)
- Type 1 External Routes (O E1)
- Routes that are injected into OSPF using redistribution from outside of the AS
- Loopback Routes
- Routes to a Loopback interface on an OSPF-enabled router
- By default, advertised as host routes with /32 subnet maska
Router Types
- Backbone Routers
- Routers which have all of their OSPF interfaces in Area 0
- Area Border Routers (ABRs)
- Routers that have interfaces in multiple areas
- Separates LSA flooding zones
- Is the primary point for area address summarization
- Maintains the LSDB for each area
- ABRs do not automatically summarize routes
- Routes to other areas appear as InterArea (IA) routes
- Internal Routers (also Normal Area Routers)
- Routers that have all their interfaces in a normal area (area 1+)
- Maintain a full LSDB of routers and links in their area
- Learn Inter-Area (IA) routes from their ABRs
- Autonomous System Boundary Routers (ASBR)
- Redistribute other areas into OSPF
- Routes that are redistributed into OSPF appear as External routes
OSPF Packets
- Hello packet (message type 1)
- When OSPF enabled, a router will send out and listen for Hello packets to form adjacencies with other OSPF routers
- DBD (DataBase Description) (message type 2)
- Adjacent routers will tell each other their known networks
- LSR (Link State Request) (message type 3)
- If a router is missing information, it will send a Link State Request
- LSU (Link State Update) (message type 4)
- LSU's are replies to LSR's
- Contains one or more LSA's (Link State Advertisements) which should be updated
-
- LSA (Link State Advertisement) is a routing update
-
- When an LSU is sent between routers, it floods the LSA information through the network
- LSAck (Link State Acknowledgement) (message type 5)
- Sent by receiving routers after getting the LSAs
- Notifies the source OSPF router that the LSA advertised by the LSU has been properly received
- The LSU will be re-sent if an LSAck is not received
OSPF LSA types
| LSA | Name | Generated By | Function | Flooding Map |
|---|---|---|---|---|
| Type 1 | Router | Normal Area Routers | Advertising router's interface and status to neighbors | Intra-area (area of origin) |
| Type 2 | Network | DR | Advertising DRs direct-connected neighbors | Intra-area (area of origin) |
| Type 3 | Summary | ABR | Advertising ABRs' areas summary | Inter-Area (multiple areas) |
| Type 4 | Summary ASBR | ABR | Advertising the presence of ASBRs | Inter-Area (multiple areas) |
| Type 5 | AS External | ASBR | Advertising external routes (to internet) | Inter-Area (multiple areas) |
| Type 7 | Not-So-Stubby Area | ASBR | Advertising external routes to NSSA areas | Inter-Area (multiple areas) |
OSPF Configuration
- Process ID
- A Process ID is the ID of the OSPF process to which to the interface belongs, and it is local to the router
- Process ID's don't need to match between routers
- It can be used to create two or more overlapping OSPF regions that don't exchange routing information
- Typically only 1 process ID is used
- Each process ID can be configured
- A Process ID is the ID of the OSPF process to which to the interface belongs, and it is local to the router
- Network
- The Network command means "Look for interfaces with an IP address that falls within a range and enable OSPF on those ports with a specific area"
- It uses a Wildcard mask to identify relevant ports, add them to an area, and then advertise the networks configured on those ports
- The Network command means "Look for interfaces with an IP address that falls within a range and enable OSPF on those ports with a specific area"
- Passive-Interface
- Passive interfaces do not form adjacencies and do not provide internal information
- Should be configured on Loopback interface
- "default" sets all interfaces to be passive by default
- IP Route
- Static route injection
- Auto-cost Reference-bandwidth
- Change the reference bandwidth when calculating cost; default is 100, should be set to 1000000 or higher
- Router ID
- Formed as an IP address, typically the highest IP address of the loopback or highest IP on the router if loopback is not configured
- Can be set manually, but best practice is to use the loopback
- Router ID updates when the OSPF process restarts (read: router reboots)
OSPF DR (Designated Router) and BDR (Backup Designated Router)
- OSPF on multiaccess segments
- On point-to-point links, OSPF router pairs form a FULL adjacency
- On multiaccess segments (such as Ethernet), where there can be multiple routers, it is inefficient for all routers to form a FULL OSPF adjacency with each other
- Rather than sharing full information, just share information with the Designated Router (DR) to fully manage routing
- If the DR goes down, there could be a big problem
- Backup Designated Router (BDR) adds redundancy
- Rather than sharing full information, just share information with the Designated Router (DR) to fully manage routing
- DR, BDR, and DROTHER
- DR (designated router) and BDR (backup designated router) are elected based on priority and router ID
- The router with the highest priority becomes the DR, and the router with the second-highest priority is BDR
- Default priority is 1, the highest is 255
- 0 says "this router will never be the DR"
- The highest Router ID is used in case of a tie
- All other routers on the network establish FULL neighbor state with the DR and BDR routers
- They will appear as FULL/DR and FULL/BDR
- The router with the highest priority becomes the DR, and the router with the second-highest priority is BDR
- DRother routers are NOT a DR or BDR
- DRothers only form full adjacencies with the DR/BDR
- On the DR/BDR, the adjacency will look like FULL/DROTHER
- DRothers remain the 2WAY state with other DRother routers
- They will appear as 2WAY/DROTHER
- DRothers only form full adjacencies with the DR/BDR
- DR (designated router) and BDR (backup designated router) are elected based on priority and router ID
Hello packets
- Sent to the OSPF Multicast address of 224.0.0.5 ('all OSPF routers')
- Hello Packet contents
- Router ID
- 32-bit number that uniquely identifies each OSPF router
- Hello Interval
- How often router sends Hello packets
- Dead interval
- How long a router waits to hear from a neighbor before declaring it out of service
- Default is 4x Hello Interval
- How long a router waits to hear from a neighbor before declaring it out of service
- Neighbors
- A list of adjacent OSPF routers that this router has received a Hello packet from
- Area ID
- The area configured for that interface
- Router priority
- An 8-bit number used to select DR (designated router) and BDR (backup designated router)
- DR and BDR IPv4 address (if known)
- Authentication Flag
- Authentication details if configured
- This is important; stops someone from accidentally or maliciously joining a router to your network
- Stub area flag
- If the area is a stub area
- Stub areas have a default route to their ABR rather than learning routs outside the area
- If the area is a stub area
- Router ID
! Configure a specific OSPF ID
Config# router ospf (process ID)
!
! Add interfaces to a specific area
Config-router# network (network address) (wildcard mask) area (area number)
!
! Set a passive interface
Config-router# passive-interface ("default"/interface name)
!
! Configure a static route (typically to default gateway)
Config-router# ip route (ip address) (network mask) (IP address of gateway to network)
Config-router# ip route 0.0.0.0 0.0.0.0 (default gateway IP address)
Requirements to form an Adjacency
- Area number must match
- Interfaces must be on the same subnet
- OSPF process must not be
shutdown - Unique OSPF Router IDs
- Matching Hello and Dead timers
- Authentication settings must match
7.IP MTU (Maximum Transmission Unit) settings must Match
8.OSPF Network Type must match
NOTE: A mismatch on 7 and 8 will allow routers to become OSPF neighbors, but OSPF will not function properly.
OSPF Neighbor States
- Establishing neighbor states
- Down - no connection
- R1 sends a multicast Hello packet to 224.0.0.5
- I am 172.16.1.1, and I have no neighbors
- If no response received, link is perceived down after 40 seconds (default)
- R1 sends a multicast Hello packet to 224.0.0.5
- INIT - Initiate 2-way Communication
- 2-Way - Response hello-packet received
- R2 replies with a unicast Hello packet to 10.0.0.1
- I am 172.16.2.1, and I see 172.16.1.1
- If it had other neighbors, it would include them here
- I am 172.16.2.1, and I see 172.16.1.1
- R1 send a unicast hello packet to 10.0.0.2
- I am 172.16.1.1 and I see 172.16.2.1
- Routers are now in a 2-way communication, but haven't exchanged any routes
- DR and BDR is elected in 2-Way state
- R2 replies with a unicast Hello packet to 10.0.0.1
- ExStart - Routers negotiate who is going to start the exchange, all traffic in unicast
- R1 sends a DBD (database description) packet
- I will start exchange with my Router ID 172.16.1.1
- R2 replies with a DBD packet
- No, I will start exchange because I have a higher Router ID 172.16.2.1
- R1 sends a DBD (database description) packet
- Exchange - Routers exchange DBD information, and respond with LSAck
- R2 sends a DBD packet with the its LSDB (link state database) summary
- R1 replies with an LSAck
- R1 sends a DBD packet its LSDB summary
- R2 replies with an LSAck
- Loading - Exchange LSRs and LSUs
- R2 sends a LSR (link state request) to R1
- I need full info on 172.16.1.0/24
- R1 sends an LSU
- R1 sends an LSR for 172.16.2.0/24
- R2 replies with an LSU
- R2 sends a LSR (link state request) to R1
- Full - Neighbors are fully adjacent
- R1 sends an LSAck acknowledging all info
- R2 sends an LSAck acknowledging all info
- Down - no connection
- Neighbor State Stages Summary
- Down: no active neighbor detected
- INIT: Hello packet is received from a neighbor
- 2-way: Neighbor responds, includes both router IDs in Hello
- Exstart: Primary and Secondary roles determined
- Exchange: Database description packets sent
- Loading: Exchange of LSRs and LSUs
- Full: Neighbors fully adjacent
Various Commands
- Enable OSPF directly on an interface
config-if# ip ospf <process ID> area <area ID>
- Modify the OSPF AD on the local router
config-router# distance <new AD value>
OSPF Mnemonics
OSPF Network Types
Breathe Fiddy, Elect 10
P2P HD, Tyrant 10
Weird nets 30 secs
Broadcast: Ethernet, FDDI, Elects DR/BDR, Hello 10 seconds
Point-to-Point and HDLC, no elections, Hello 10 seconds
Everything else, Hello 30 seconds
(some of them elect DR, some don't, didn't fit the mnemonic)
OSPF Neighbor States
Dinit 2-Wexstart Exchange LoFull
- Down
- Init
- 2-Way
- ExStart
- Exchange
- Loading
- Full