>_nexthopreachable

JNCIP-ENT: Advanced OSPF Options

Ali Bahadır Coşkun17 min read

This is the ninth lab in my JNCIP-ENT series. It continues from the OSPFv3 and authentication lab, and it uses the same OSPFv2 domain we first built in the multi-area OSPF and route summarization lab. This time we will add a sixth vMX router and a new Area 3, and then we will fix and tune the topology.

In this lab we will first connect an area that has no way to reach the backbone. Then we will stop routes from leaking where we do not want them, and we will tune the metrics.

Before starting, let's reset the lab. Lab 8 left OSPFv3 running dual-stack. We will not use ospf3 here so we will deactivate it to keep it simple:

junos
deactivate protocols ospf3

Commit this on the five existing routers. We leave the OSPFv2 MD5 authentication on the R1-R2 backbone link alone. It is per-interface, so the new links in this lab are not affected by it.

Topology

We added a new router and a new area. The direct R1-R4 link is also new, but we will not cable it until the second part.

Area 3 hangs off R4. R4 sits in the middle of Area 1. So Area 3 has no connection to the backbone. We will solve this problem by using virtual link.

Area 3 Has No Way Out

First we will build Area 3 and see exactly what an ABR without a backbone attachment can and cannot do.

R4 becomes an ABR:

junos
set interfaces ge-0/0/3 unit 0 family inet address 10.3.0.1/30set protocols ospf area 0.0.0.3 interface ge-0/0/3.0

R6:

junos
set interfaces ge-0/0/0 unit 0 family inet address 10.3.0.2/30set interfaces ge-0/0/1 unit 0 family inet address 10.3.10.1/24set interfaces lo0 unit 0 family inet address 10.3.255.6/32set routing-options router-id 6.6.6.6set protocols ospf area 0.0.0.3 interface ge-0/0/0.0set protocols ospf area 0.0.0.3 interface ge-0/0/1.0 passiveset protocols ospf area 0.0.0.3 interface lo0.0 passive

Commit both. The Area 3 adjacency between R4 and R6 comes up Full:

junos
show ospf neighbor

Now check who can see Area 3. On R1, R2, and R5, sitting in Area 0 and Area 2:

junos
show route 10.3.0.0/16

Nothing. R6's loopback and access LAN are invisible from the backbone and from Area 2. So far this matches the textbook expectation.

But check R3, which sits in Area 1 alongside R4:

junos
show route 10.3.0.0/16

R3 sees all three Area 3 prefixes, with real routes. And from R6:

junos
show route protocol ospf

R6 sees Area 1 too: the R1-R3 transit link, R3 and R4's loopbacks, both of R4's access LANs, all present as real inter-area routes.

This is not the textbook answer. The rule usually quoted is an ABR only originates summary LSAs if it is attached to the backbone, and by that rule R4 should inject nothing anywhere. Junos does not enforce OSPF that strictly. This is documented behavior, not a bug: RFC 3509, "Alternative Implementations of OSPF Area Border Routers", describes exactly this relaxation, sometimes called active backbone detection. An ABR with no real backbone connection still summarizes between the non-backbone areas it directly touches. R4 touches Area 1 and Area 3 directly, so it bridges the two, backbone attachment or not.

What R4 genuinely cannot do is reach anything past those two areas. It has no interface in 0.0.0.0 at all, so there is nothing for it to inject Area 3 into, and nothing from Area 0 or Area 2 for it to relay into Area 3 either. R5's two 203.0.113.x externals still flood into Area 3 unchanged, since Type 5 is domain scope regardless of any of this, but no route for them ever appears on R6:

junos
show route 203.0.113.0/24

Nothing. No Type 4 ever reaches Area 3 for R5, because originating one would require R4 to know a cost via the backbone, which it does not have. The LSA can sit in the database and still be operationally useless.

The adjacency is Full, Area 1 and Area 3 already trust each other, and the failure is real, it is just narrower than "zero routes anywhere." R4 is a bridge between two rooms with no door to the rest of the building — Area 0, Area 2, and every external route stay unreachable from Area 3 until R4 gets a real (or virtual) backbone attachment.

A virtual link tunnels OSPF packets through a transit area. It gives a stranded ABR a logical backbone attachment. R4 needs to reach Area 0, and Area 1 sits between R4 and R1, so Area 1 is the transit area.

Both ends configure the virtual link under Area 0, and each end points at the other end's router ID.

R1:

junos
set protocols ospf area 0.0.0.0 virtual-link neighbor-id 4.4.4.4 transit-area 0.0.0.1

R4:

junos
set protocols ospf area 0.0.0.0 virtual-link neighbor-id 1.1.1.1 transit-area 0.0.0.1

R4 now has an area 0.0.0.0 stanza that contains a virtual link.R4 is now logically attached to the backbone.

Two important constraints:

  • The transit area cannot be a stub area. If Area 1 were still the totally stubby area from Lab 7, this would not work.
  • The neighbor ID is a router ID, not an address. This is the one place where a pinned router ID is a dependency.

Verify:

junos
show ospf neighborshow ospf interface

A new adjacency appears. The interface is named vl-1.1.1.1 on R4 and vl-4.4.4.4 on R1. That is the vl- prefix plus the far-end router ID.

Now Area 3's prefixes appear as inter-area routes everywhere, and R6 finally sees the rest of the domain:

junos
show route 10.3.0.0/16run ping 10.3.10.1 source 10.0.255.2 count 2

The ping from R2's loopback to R6's access LAN crosses the backbone, the transit area, and Area 3.

The virtual link works but it is not a long term solution because of the reasons below:

  • It is a control-plane feature only. The virtual link carries OSPF adjacency and LSA flooding. It does not carry data. SPF still computes the shortest physical path to every destination, and that path may have nothing to do with the tunnel. So what you see in the database and what packets actually do can be different, and troubleshooting gets confusing.
  • It depends on the transit area staying healthy and staying regular. You forget about the virtual link and make Area 1 stub and Area 3 goes dark.
  • It is a bridge, not an architecture. The correct fix is a real backbone connection.

Now we fix the problem the right way by cabling the R1-R4 link and putting it in Area 0.

R1:

junos
set interfaces ge-0/0/2 unit 0 family inet address 10.0.0.6/30set protocols ospf area 0.0.0.0 interface ge-0/0/2.0

R4:

junos
set interfaces ge-0/0/4 unit 0 family inet address 10.0.0.5/30set protocols ospf area 0.0.0.0 interface ge-0/0/4.0

R4 now has a real physical backbone attachment. Let's remove the virtual link:

junos
delete protocols ospf area 0.0.0.0 virtual-link neighbor-id 4.4.4.4
junos
delete protocols ospf area 0.0.0.0 virtual-link neighbor-id 1.1.1.1

The vl- interface is gone, and Area 3 is still fully reachable. R4 is a real ABR now.

There is still a problem. R4's access LANs (10.1.10.0/24 and 10.1.20.0/24) are Area 1 prefixes. R1 is also in Area 1. So from R1, those LANs are intra-area routes, and the intra-area path runs R1 to R3 to R4. There is now a direct R1-R4 cable but it is not used:

junos
traceroute 10.1.10.1 source 10.0.255.1

Two hops, through R3. The direct link isn't being used for this traffic.

This is not a metric problem, and you cannot fix it with a metric. OSPF always prefers an intra-area path over an inter-area path, no matter the cost. The direct R1-R4 link is in Area 0. A route to an Area 1 prefix that is computed across an Area 0 link is inter-area by definition, and inter-area always loses to intra-area. You could set the cost of the R1-R3-R4 path to 10,000 and traffic would still take it.

The obvious idea is to move the direct link into Area 1. But then Area 0 loses the direct R1-R4 connection we just built, and we are back to needing a virtual link. This is what RFC 5185 is for.

Multi-Area Adjacency (RFC 5185)

A logical interface can belong to more than one area. It is primary in exactly one area and secondary in every other area. Each secondary adjacency is advertised as a point-to-point link in its area. So the link becomes a real intra-area link in that area too, and it is eligible for the intra-area best-path calculation.

The R1-R4 link is already primary in Area 0. We add it to Area 1 as secondary.

R1:

junos
set protocols ospf area 0.0.0.1 interface ge-0/0/2.0 secondary

R4:

junos
set protocols ospf area 0.0.0.1 interface ge-0/0/4.0 secondary

Commit, then look at the interface:

junos
show ospf interface

The same physical interface now appears twice. Once under Area 0.0.0.0, and once under Area 0.0.0.1. The Area 1 is in a state of PtToPt.

We did not configure point-to-point. Junos does it automatically, because RFC 5185 requires all secondary multi-area adjacencies to be point-to-point.

junos
show ospf neighbortraceroute 10.1.10.1 source 10.0.255.1

There are now two adjacencies to R4 over one wire, one per area. And the traceroute is one hop. The direct link is now an intra-area Area 1 link, the intra-area SPF can see it, and it wins on cost.

If you want the direct link to be a backup instead of the preferred path, which is the usual reason to configure a multi-area adjacency, weight the secondary:

junos
set protocols ospf area 0.0.0.1 interface ge-0/0/2.0 metric 300

Now the R1-R3-R4 path wins in normal operation, and the direct link takes over only when R3 fails.

Controlling Redistribution

Everything so far has been about getting routes in. Now we will talk about stopping them.

Junos rejects everything into OSPF by default. This is why R5 needed an explicit export policy in Lab 6 to advertise its edge subnets. OSPF already advertises the interfaces you put into it, by flooding router LSAs.

Right now R5 leaks two externals, and nothing else in the domain originates any:

junos
show ospf database external

A redistribution policy can filter by prefix, but it cannot count. If someone writes from protocol bgp then accept on a router that carries a full table, the database is gone and so is every router in the area. But we can limit the prefixes we export.

R5 exports two, so set the limit below that to see the failure:

junos
set protocols ospf prefix-export-limit 1

Commit and look from any router. R5's externals stop being advertised. Going over the limit does not export a partial set. It stops exporting completely.

The breach is also logged:

junos
show log messages | match ospf

Set it to 10, and the externals come back:

junos
set protocols ospf prefix-export-limit 10

Setting this a comfortable margin above your expected external count, on every router that redistributes anything can save a network.

The Import Policy Trap

Say we do not want R3 to install R5's external routes into its routing table. The instinct is an import policy but import policies don't work well with OSPF.

R3:

junos
set policy-options policy-statement block-externals term ext from route-filter 203.0.113.0/24 orlongerset policy-options policy-statement block-externals term ext then rejectset protocols ospf import block-externals

Commit, then look at all three layers.

The link-state database:

junos
show ospf database external

The external LSAs are still there, unchanged. An import policy does not touch the link-state database.

The tree database, which is the SPF result:

junos
show ospf route extern

The routes are still there too. An import policy does not affect the SPF calculation either.

The routing table:

junos
show route protocol ospf

Now they are gone. This is the only thing the import policy did. It blocked the copy from the tree database into the routing table.

The LSAs are still flooding to everyone. R4 has no import policy, so R4 installs the external routes normally. If R4 forwards traffic for 203.0.113.0/25 toward R3, because R3 is on the path to R5, then R3 has no route for it. R3 falls back to whatever it does have, which in a real network is a default route pointing back the way the traffic came. The packet goes back to R4. R4 sends it to R3 again.

You have built a forwarding loop out of a policy that was supposed to be a filter. Import policies do not remove routes from the network. They remove routes from one router's routing table, while leaving that router still in the forwarding path for them. The case for using one is almost always a case for fixing the redistribution at the source instead. Clean up:

junos
delete protocols ospf import block-externals

Preference and Redistribution Loops

The other way redistribution misses is preference. These are the Junos defaults that matter here:

Route sourcePreference
Direct0
Static5
OSPF internal10
Aggregate130
OSPF external150

Confirm it on any router. OSPF internal is 10, and R5's externals are 150:

junos
show route protocol ospf

The problem is that aggregate routes (130) beat OSPF external routes (150). So if a router holds an aggregate for a prefix, and it also learns that prefix as an OSPF external, it uses its own aggregate. If that aggregate is a discard, or if it points somewhere that then points back into OSPF, traffic loops between the two redistribution points.

The fix is to move OSPF external preference below the aggregate preference:

junos
set protocols ospf external-preference 120

Any value below 130 works. Now the OSPF external wins over a local aggregate, and the loop does not form.

The general rule is when you redistribute between protocols, and the source protocol has a worse (higher) preference than the protocol you redistribute into, you can get loops and suboptimal routing. Multiple redistribution points make it worse. The usual fix is not clever policy, it is fixing the preference values so the intended path wins on merit.

Reference Bandwidth

OSPF cost comes from interface bandwidth against a reference value. The Junos default reference bandwidth is 100 Mbps. So every interface at or above 100 Mbps costs 1.

junos
show ospf interface detail

Every ge interface in this topology shows a metric of 1. A gigabit link and a ten-gigabit link look the same to SPF, which means SPF is choosing paths by hop count, not by capacity. On any modern network the default reference bandwidth is simply wrong.

Fix it. This must be the same on every router in the domain, or routers will disagree about link costs:

junos
set protocols ospf reference-bandwidth 100g

Commit on all six routers, then look again:

junos
show ospf interface detailshow ospf route

Metrics change, and path costs change too.

Two things to keep in mind:

  • Manually configured interface metrics are not affected. If you set metric 300 on the secondary earlier, it stays 300. Reference bandwidth only drives the automatically calculated costs.
  • Mismatched metrics on the two ends of one link cause asymmetric routing. Each router runs its own SPF against its own view. Set link metrics on both ends, or on neither.

The Overload Bit

The overload bit tells the rest of the domain "route around me if you can." It is borrowed from IS-IS. It exists mainly for two situations: a router about to go into maintenance, and a router with many BGP peers that should finish establishing its sessions before it accepts transit traffic.

All transit interface metrics on the overloaded router jump to the maximum, 65,535. The router floods that in its router LSA, everyone reruns SPF, and the huge costs push transit traffic onto other paths.

Thanks to the multi-area adjacency, there is now a real alternative path. Traffic from R1 to R4's access LAN can go direct or through R3. If you set the secondary metric to 300 earlier, traffic currently goes through R3. Let's overload R3 and watch it move:

junos
set protocols ospf overload

Commit, wait for SPF, then look:

junos
traceroute 10.1.10.1 source 10.0.255.1show route 10.1.10.0/24

Traffic now takes the direct R1-R4 link. The route metric through R3 has grown by 65,535.

Three details matter:

  • Overload does not blackhole the router. Traffic destined to prefixes that live on R3 still reaches R3. Only transit traffic reroutes. And if there is no alternative path, traffic still transits the overloaded router.
  • The timer only initializes when RPD initializes. set protocols ospf overload timeout 300 does not start counting down when you commit it. It starts when the routing protocol process starts. Configure the timeout before the reboot.
  • Without a timeout, it is permanent. The metrics revert only when you delete the statement and commit again.

Clean up:

junos
delete protocols ospf overload

Summary

This lab adds four ideas to the previous OSPF labs:

  • A virtual link gives a stranded ABR a logical backbone attachment through a transit area, but it is control-plane only and it is a temporary fix. A real backbone link plus a multi-area adjacency is the real fix, and it lets one interface live in two areas at once.
  • OSPF always prefers an intra-area path over an inter-area path, no matter the cost. You cannot fix that with a metric. You fix it by making the link intra-area with a secondary adjacency.
  • An import policy only blocks the copy from the tree database into the routing table. It does not touch the LSDB or the SPF result, so the router stays in the forwarding path and you can build a loop. prefix-export-limit and correct preference values are the safer tools, and the best fix is usually at the source.
  • The default reference bandwidth of 100 Mbps makes every fast link cost 1. Set reference-bandwidth consistently across the domain, and use the overload bit to move transit traffic off a router without blackholing it.