OSPF NSSARFC3101 describes an OSPF area called not-so-stubby area (NSSA). The motivation behind NSSA is to allow OSPF Stub areas to carry External routes (routes learned using other routing protocols like RIP, EIGRP, BGP, etc). Stub areas are defined as areas that are not capable of importing routes external to OSPF.
N-bit
RFC 3101 defines a new bit N in the Options field and a new Type 7 LSA to support NSSA. Together, the N-bit (NSSA supported bit) and E-bit (External Routing Capability of the area) reflect an interface's external LSA flooding capability. When the peers exchange Hello messages, they check for the N-bit (should be set to 1) and E-bit (should be set to 0), along with Area ID. A mismatch in the Options field could result in failed adjacency.
Type 7 LSA
External routes are imported into OSPF NSSA as Type 7 LSAs by NSSA ASBR. The NSSA ASBR redistributes routes from different routing protocol(s) into OSPF, and vice versa. This router sets the E-bit in Router LSA flag. The ASBR originates a separate Type 7 LSA for each external route.
Type 7 LSAs are only flooded within the originating NSSA. The NSSA ABR (the routers connecting NSSA to backbone area 0) translates Type 7 LSA into Type 5 LSA, and flooded into the OSPF topology.
In Cisco IOS, by default, the NSSA ASBR always set the N/P-bit (Propagate) in the Options field of Type 7 LSA. The P-bit is not set only when the NSSA ASBR and NSSA ABR are the same router for the area. The P-bit tells the NSSA ABR to translate a Type 7 LSA to Type 5 LSA. These translated Type 5 LSAs copy the Forwarding Address (FA) from Type 7 LSA.
The following packet capture shows a Type 7 LSA.
Type 7 Translator Election
If multiple NSSA ABR routers are present, it is recommended that not all ABRs perform Type 7-to-5 translation to avoid routing loops. RFC 3101 defines a configurable parameter NSSATranslatorRole which specifies whether a router will perform Type 7-to-5 translation or not. Cisco IOS does not support this parameter yet. Cisco IOS uses Router ID to elect the Type 7-to-5 translator.
If there exists multiple NSSA ABRs capable of performing Type 7-to-5 translation, the router advertising with higher Router ID is elected as the translator. The NSSA ABR that is no longer required to perform translation, flushes its Type 5 LSAs.
Sample Scenario
The configuration of the routers is as below:
The ASBR router learns about 101.1.1.1/32 via RIP as seen below:
The ASBR router performs redistribution between RIP and OSPF. Thus, ASBR router is responsible for originating Type 7 LSAs. Also note that OSPF is enabled on all interfaces on this router including the interface (Fa0/0) connecting to the R1 router. This causes ASBR router to set the FA address of Type 7 LSA for prefix 101.1.1.1/32 to IP address of R1 router i.e. 100.100.100.1.
The NSSA-External Type 7 LSA generated by ASBR router can be seen as below:
This Type 7 LSA is only forwarded in NSSA and is not forwarded out the NSSA area 10. ABR1 and ABR2 routers receive this LSA 7 with P-bit (Propagate) set to 1.
This causes both, ABR1 and ABR2, routers to perform the role of Type 7-to-5 translator. However, when ABR1 receives translated Type 5 LSAs from ABR2 with a higher Router ID (4.4.4.4) compared to its own RID (3.3.3.3), it flushes its Type 5 LSAs.
ABR2 copies the Forwarding Address (FA) from Type 7 LSA and inserts the same in Type 5 LSA. The following output shows that R5 router receives Type 5 LSA from ABR2 (4.4.4.4) router only.
Since FA 100.100.100.1 does not belong to the same area as R5, it performs an inter-area (IA) lookup on Type-3 LSA. It finds that ABR1 and ABR2 are advertising the route to 100.100.100.0/24 with a metric of 51 and 101, respectively.
R5 router now needs to find out the metric to reach the ABRs. To find out, it looks up the Type 1 Router LSAs in LSDB. From the below output, the metric to reach both ABRs is 10.
The alternative way to find out the metric to ABRs is as below:
So, the intra-area cost to reach ABRs is 10. Also, ABR1 and ABR2 reported a cost of 51 and 101 to the forwarding address 100.100.100.1, respectively. So, the total forward metric through ABR1 is 61, and through ABR2 is 111. Hence, R5 chooses ABR1 as the next-hop for the route 101.1.1.1/32, although, the route is originated by ABR2, type 7-to-5 translator, the traffic does not actually flow through ABR2.
Thus R5 installs the path through ABR1 with the default redistribution metric of 20 for OSPF E2 route and forward metric of 61.