OSPF - jibingl/CCNA-CCNP GitHub Wiki
OSPF (Open Shortest Path First)
| Version | RFC | Support |
|---|---|---|
| OSPFv2 | rfc2328 | IPv4 |
| OSPFv3 | rfc2740 | IPv4 and IPv6 |
- Become neighbors with other routers connected to the same segment;
- Exchange LSAs (Link State Advertisement) with neighbor routers;
- Calculate the best routes to each destination, and insert them into the routing table.
- An OSPF area is a set of routers and links that share the same LSDB.
- The backbone area (area 0) is an area that all other areas must directly connect to.
- All areas must have at least one ABR connect to the backbone area. (Best-practice for design)
- An ABR connect maximum of 2 areas. (Best-practice for design)
- OSPF interfaces in the same subnet must be in the same area. (Best-practice for design)
- OSPF area should be contiguous.
- Cost to a destination is the total cost of the outgoing/exit interfaces' costs.
Topology example and Key-info:
WAN 144.14.14.1
|
.---------------AREA 0-------------------|----------.
| | |
| | |
| DR DR BDR g0/0 |
192.168.2.0 [=]------ g1/1-(R2)-g0/0 --------------- g1/1-(R1)-f1/0 ---------[=] 172.16.1.1
| f1/0 .10. g2/2 DR |
| BDR| |BDR |
| | .20. | |
| | 10.0.X.0/30 .40. | |
| DR| |DR |
| f1/0 .30. g2/2 DR |
192.168.3.0 [=]------ g1/1-(R3)-g0/0 --------------- g0/0-(R4)-g1/1 ---------[=] 192.168.4.0
| DR BDR DR s1/0 |
| | |
| | |
`---------------OSPF BROADCAST NET-------|----------`
|
OSPF PPP NET | 10.0.50.0/30
|
.---------------AREA 1-------------------|---------.
| s1/0 |
| (R8)-g0/0 -----. .----- g0/0-(R5) |
| DR \ / DROther |
| \ / |
| [=] 172.16.0.0/24 |
| / \ |
| BDR / \ DROther DR |
[=]------ g1/1-(R7)-g0/0 ----` `----- g0/0-(R6)-g1/1 ------[=]
| |
`---------------OSPF BROADCAST NET-----------------`
R2#show ip ospf database
.-------------------------------------.
| LSDB (area0) | .---routers generate-.
| Router LSAs | | RID:3.3.3.3 |
| .------. .------. .------. .------. | | Net:192.168.3.0/24 |
| | LSA1 | | LSA1 | | LSA1 | | LSA1 |-|------>| Cost:100 |
| `------` `------` `------` `------` | `--------------------`
| .------. .------. .------. .------. | .---routers generate-.
| | LSA1 | | LSA1 | | LSA1 | | LSA1 |-|------>| RID:3.3.3.3 |
| `------` `------` `------` `------` | | Net:10.0.20.0/30 |
| Network LSAs | | Cost:1000 |
| .------. .------. .------. | `--------------------`
| | LSA2 | | LSA2 | | LSA2 |----------|------>.---DR generates-----.
| `------` `------` `------` | | DR-RID:3.3.3.3 |
| AS-external LSA | `--------------------`
| .------. | .---ASBR generates---.
| | LSA5 |----------------------------|------>| ASBR RID:1.1.1.1 |
| `------` | `--------------------`
`-------------------------------------`
*ASBR (Autonomous system boundary router) is R1 that connects to external network, normally Internet.
*ABR (Area Border Router) is R5 or R4, depends on context, that connects two areas.
*In OSPF broadcast network, DR/BDR election rule (High-Low): interface-priority --> router-id --> interface-ip. "First placement" rule.
*When DR is down, current BDR becomes new DR even though existing of another higher-priority interface that will become new BDR.
Cost = Reference Bandwidth / Exit-Interface Bandwidth
Routes cost calculation (Reference bandwidth 100000):
- Form R1 to 192.168.20 costs 200 - R1 g1/1 (100) + R2 g1/1 (100)
- From R1 to R2 costs 101 - R1 g1/1 (100) + R2 loopback (1)
- From R1 to 192.168.3.0 costs 1200 - R1 g1/1 (100) + R2 f1/0 (1000) + R3 g1/1 (100)
CLI configuration example:
R1(config)#router ospf 1 //Process ID is locally significant. Routers with different process IDs can become neighbors.
R1(config-router)#network 10.0.10.0 0.0.0.3 area 0
R1(config-router)#network 10.0.40.0 0.0.0.3 area 0
R1(config-router)#network 172.16.1.2 0.0.0.0 area 0
R1(config-router)#passive-interface f1/0
R1(config-router)#default-information originate
R1(config-router)#router-id 1.1.1.1
R1(config-router)#maximum-path 8 //Change load-balancing paths from 4 to 8
R1(config-router)#distance 85 //Change administrative distance from 110 to 85
R1(config-router)#auto-cost reference-bandwidth 100000 //Default is 100Mbits/s
R1(config-router)#passive-interface default //Set all interfaces to passive, then
R1(config-router)#no passive-interface g1/1 //specify an interface as active
R1(config-router)#shutdown //Shut the OSPF process 1 down
R1(config)#interface g1/1
R1(config-if)#ip ospf 1 area 0 //Active OSPF directly on an interface
R1(config-if)#ip ospf cost <1-65535> //Manually set the interface OSPF cost, or
R1(config-if)#bandwidth <1-10000000> //Change the interface bandwidth (It won't change speed of the interface)
R1(config-if)#ip ospf priority <0-255> //Change interface priority (default is 1)
R1(config-if)#ip ospf hello-interval <1-65535> //Change Hello message sending interval (default 10s)
R1(config-if)#ip ospf dead-interval <1-65535> //Change Dead timer-count (default 40s)
R1(config-if)#ip ospf network broadcast //Set as broadcast OSPF network. Other types are point-to-point, non-broadcast, and point-to-multipoint
R1(config-if)#ip ospf authentication-key <string> //Set password for OSPF neighbors communication
R1(config-if)#ip ospf authentication //Enable
NEIGHBOR REQUIREMENTS:
- Area number must match
- Interfaces must be the same subnet
- No shutdown to OSPF process
- Hello/Dead intervals must match
- Router ID must unique
- Authentication settings must match
- OSPF Network type must match
- IP MTU settings must match
Under 7 and 8, neighbors can be formed but OSPF operate improperly.
.--------------------------------------area0 (backbone)-.
|-----R0(+)-----------------[=]---------------[=] |
`----------------------------|-----------------|--------`
R1(+)---------------(+)R2 (+)R3
.------/|\-area1. .------/|\-area2. .------/|\-area3.
| / | \ | | / | \ | | / | \ |
| / | \ | | / | \ | | / | \ |
| (+) (+) (+) | | (+) (+) (+) | | (+) (+) (+) |
| | | | | | | | | | | | | | |
`---------------` `---------------` `---------------`
Issues: area 1 has no ABR connect to backbone area (area 0); R2 connects to too many areas (three areas).
.--------------------------------------area0 (backbone)-.
|-----R0(+)--------[=]------------------------[=] |
`----------------/-----\-----------------------|--------`
R1(+) (+)R2 (+)R3
.area1----/-----. .-----\----area2. .-------|--area1.
| / /\ | | /\ \ | | / | \ |
| / | \ | | / | \ | | / | \ |
| (+) (+) (+) | | (+) (+) (+) | | (+) (+) (+) |
| | | | | | | | | | | | | | |
`---------------` `---------------` `---------------`
Issues: area 1 is not contiguous, instead it is divided into two parts.