OSPF: WHAT IS A STUB NETWORK?

(This is part two in a series that asks: what the h*ck (heck) is the difference between stub areas and networks? If you missed part one, click here to get up to speed!)

 

When you’re first getting to grips with your router’s OSPF database, you might see mention of something called a “stub network”. And let me tell you: never before have I seen a phrase so clumsily defined. Even the RFC for OSPF makes an absolute hash of it. Let this be a warning from history: don’t write an industry-standards document when you’re high.

First of all, let’s clear up some potential confusion: OSPF stub *networks* have nothing whatsoever to do with stub *areas*. It’s just a needlessly confusing use of language. You know: like when your mother says she “loves” you, yet refuses to buy you a Nintendo Switch.

Stub networks are actually to do with the way that your router works out the topology of your network. Theoretically, a stub network is a network that has only one router on it, like a LAN. This is the definition in the RFC itself. But, as we’ll see, this definition isn’t true at all! Isn’t networking fun? Yes. Lots of and lots of….. fun.

You’ll see the phrase “stub network” mentioned in the LSA database. And I’m a great believer in bringing everyone along, no matter what your technical level. So, to really understand what stub networks are, we need to talk about the famous and exciting world of LSAs.

 

LINK STATE ADVERTISEMENTS

You might know that each router in an OSPF domain creates a thing called a Link State Advertisement. LSAs are a list of all the links on the router, the IP addresses and subnet masks, the costs, and so on.

Each router creates an LSA about itself, and send it to all its neighbors. In turn, these neighbors pass on all the LSAs they’ve received to all their neighbors – until every router in an area has other router’s LSAs in its database.

Each router can then put all these LSAs together, with all the information about the links, like pieces of a nerdy jigsaw puzzle, to create the entire area’s network topology.

There’s actually a few different kinds of LSA, and each one serves a different purpose. For example, some LSAs are made for routers in one area. Some LSAs are used to advertise routes between areas. Some LSAs are even made for routes to IP addresses that live outside of the OSPF network altogether.

In total, there’s seven kinds of LSA (in IPv4. There’s even more in IPv6!). Today though, we only care about one of them: Router LSAs, otherwise known as Type 1 LSAs.

 

ROUTER LSAs

Each router in an area creates a Router LSA. These LSAs are the absolute building blocks of OSPF: they contain the router’s ID, all the links on the network, the IP prefixes on those links, the cost of the link, and so on. With so much detail in an LSA, it’s easy to imagine how a router could gather up all the Router LSAs in an area, and put them together to build an entire network map. Go on: imagine it. Isn’t it easy? It’s so easy to imagine things!

In fact, let me let you in on a secret: you can imagine anything you want to, at any time – and you don’t even need to pay! You could imagine eating ice cream; you could imagine being bigger than a tree; you could even imagine being one of those Ryan Gosling fellas they have nowadays. And here’s the best part: no-one ever needs to find out. It’s your special secret, just for you.

But hey, forget I said any of that: let’s talk LSAs.

Now, in an earlier post on stub areas (as opposed to stub networks!) we made the sweet sweet topology you can see above. Today we’re going to focus on Router 4, in area 2.

The command show ip ospf database gives you a list of all the LSAs on a router. Here’s the result of that command on Router 4:

Actually, this isn’t the full output – it’s just the top bit, which shows us the list of Type 1 Router LSAs that Router 4 has received.

This command shows us that Router 4 has received three Router LSAs, one for each router in area 2 (including itself).

Now, let’s get sexy: shall we dig a little deeper, and look at the contents of an LSA? Come on. I dare you. Fancy it? Are you brave? Okay, let’s do it.

 

HOW TO READ THE CONTENTS OF THE OSPF DATABASE

If you want to see the contents of an LSA, use this command: show ip ospf database router x.x.x.x. X is the Link ID we’re interested in. The word “router” in this command means that want to see Router LSAs, aka Type 1 LSAs.

Let’s look at the Router LSA that Router 4 makes.

This is a router with lots of links attached to it. So for now, let’s just look at the beginning of the output.

At the very top you see stuff you can mostly ignore – the checksum, the LS age, the sequence number, etc. The only really interesting thing is the number of links attached to this router: 9 links. Nine links. Nine! That’s almost ten! Wow.

Anyway, forget that: we’re much more interested in what comes next.

Check it out: in this screengrab we see information about two prefixes connected to loopbacks on the router: 4.4.1.0/24, and 4.4.2.0/24. We see that these loopbacks have a metric of 1. We also see that both of these links are “connected to a Stub Network”.

So, what does this actually mean?

 

OKAY, ENOUGH CHAT: WHAT ON EARTH IS A STUB NETWORK?

Well, if you want the very worst and most unhelpful definition, check out the the OSPF RFC itself: “A stub network’s vertex has only incoming edges.” Great. Thanks for that. Super helpful. That’s really cleared things up for me. Yes. Great! Great.

Let’s try to explain it a bit better. In the OSPF RFC, waaaaaay down on page 207, you’ll find that an OSPF router can have four types of interface:

Type  Description
 __________________________________________________
 1    Point-to-point connection to another router
 2    Connection to a transit network
 3    Connection to a stub network
 4    Virtual link

It makes sense that OSPF cares about the kind of link – it needs this information to draw the topology.

To try to help understand what each link type does, the RFC contains this ultra-retro ASCII-art drawing.

Let’s start with transit networks. The RFC says “Transit networks are those capable of carrying data traffic that is neither locally originated nor locally destined” Seems like a fair description. Here’s the twist though: that’s not quite right.

What a transit network actually is, is any network that requires a designated router. This could be an ethernet LAN, or it could be a frame-relay network with multiple virtual circuits. Either way, if you need a DR, you’re a transit network.

A stub network, from this diagram, seems to be any network with just one router on it, like a LAN interface.

And point-to-point seems pretty simple: it’s two router connected directly together.

But here’s where things get interesting: if you connect two Cisco routers directly together via ethernet ports, they’ll default to being transit networks – even though they’re really point to point!!

And here’s where things get even funkier: point-to-point links ALSO appear as stub links!!

 

WHAT THE ACTUAL F*CK??

Okay, calm down. I said calm down!! I’ll explain.

First: why do point-to-point ethernet lines appear as transit networks?

Well, here’s the thing: if you plug two routers together directly via ethernet, your router can’t tell for sure that there isn’t a switch in between them. If there were a switch, you could add even more routers. For that reason, ethernet ports default to being OSPF “transit” networks. Let’s look at an example.

Remember earlier, when we saw the top of the output of the OSPF database?, Well, if we kept looking down we’d see this: the entry in the LSA for the 192.168.34.0/30 network – the network that connects routers 3 and 4 together. Even though there’s only two routers in this /30 network, OSPF has still decided it’s a transit network, and thus requires a designated router.

You can change this, by configuring an interface with the command ip ospf network point-to-point. In fact, I did this, on the ethernet port on the 192.168.45.0/30 network. And look what happens: it’s no longer a transit network – but confusingly, we now have TWO entries in the OSPF database!

The first entry says that this is a point-to-point link. Finally it’s got something right. Take a look: this entry contains the IP on the interface on router 4, and also the router ID (or “link ID) of Router 5. Our router will be able to look in the LSA it receives from Router 5 to get the other end of the link, and put the pieces of the jigsaw together. Routers are smart. Unlike humans, who are all idiots.

Then look underneath: we see the 192.168.45.0/30 network mentioned for a second time – but this time as a stub network. Why?

Basically, the way that OSPF advertises point-to-point links is a bit convoluted, but it comes from a good place: historically, point-to-point links didn’t have to have IP addresses on them. So by default, they were advertised in the LSA as Type 1 links (point-to-point). If the link did happen to have an IP address on it, then this is additionally advertised as a Type 3 link (stub link). It’s fiddly, but it works!

This information is in the RFC – but my god is it written badly. And that’s why I wanted to take some time to explain all of this. Because without all that background, understanding this concept is super tricky. But once you know what’s going on behind the scenes, it’s actually kind of easy!


So, there you have it. Stub networks are a kind of network that OSPF uses to draw the network map; stub areas are a special kind of area where you can filter out IPs and replace them with a default route.

I hope this post helped you to understand, and to get a little bit closer to your CCNA or CCNP. If you find my blog useful, I’d love you to share it with your friends and co-workers, whether via a Twitter/Facebook/LinkedIn post, or just emailing it to them directly. And please follow me on Twitter to find out when I make new posts, at @NetworkFunTimes.

Thank you for reading!

Leave a Reply

Your email address will not be published. Required fields are marked *