(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”. Let’s get something clear that might be confusing you: OSPF stub *networks* have nothing whatsoever to do with OSPF 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 (at least, there are 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.
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 guys they have nowadays. And here’s the best part: no-one ever needs to find out what you’re imagining. It’s your special secret, just for you.
But hey, forget I said any of that: let’s talk LSAs.
Take a look at the topology in that diagram. Today we’re going to focus on Area 2. You’ll notice that three routers have a presence in this area: Router 3, Router 4, and Router 5.
The command show ip ospf database gives you a list of all the LSAs that your router knows about. In this screenshot we can see 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
Let’s look at the Router LSA that Router 4 makes. In reality, Router 4 only has two physical links on it, but you can see from the diagram above that I’ve added six /24 ranges to the router’s loopback.
If you want to see the contents of a router LSA (aka a Type 1 LSA), use this command: show ip ospf database router x.x.x.x. X is the Router ID we’re interested in.
￼Let’s just look at the first part 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.
Now in reality, we can see that there’s only two links. But each range on the loopback counts as an extra link. So, there’s the actual loopback address of 18.104.22.168/32, plus the six pretend loopback prefixes, plus the two actual physical interfaces – giving us a total of nine links.
In this screengrab we see information about two prefixes connected to loopbacks on the router: 22.214.171.124/24, and 126.96.36.199/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 the full story.
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. 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 a Type 1 links (point-to-point). (Don’t be confused when I say Type 1 there: I’m talking about the first of the four link types we mentioned above.) 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 not so bad.
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!