So how does a router
make its routing decisions?
Well, it uses a routing table.
Just like our switches
used a Mac address table or a CAM table,
we're going to use routing tables
to decide where our packets need to go
inside and outside of our networks.
Now these routing decisions are going to contain
layer three information,
and they're going to do a layer three to layer two map.
The router is going to use an arp cache to map an IP address
to a given Mac address,
and this way it knows inside its local area network,
which IPs are going to relate to which Mac addresses.
Now, each packet forwarding decision
is then going to be based on its internal routing table.
Those internal routing tables
are really focused on the logical address side of things,
or that IP address.
So, let's dig a little bit deeper into these routing tables
to really see how they work.
These tables are kept by the router,
and they help them determine which route
is best fit for them as they're trying to route the traffic
throughout the different networks.
Now, a route entry has a prefix,
and the longer the prefix is
the more specific that network is.
So if we look here at this chart,
I have three different networks showing up.
There's 125.0.0.0,
I have 161.5.0.0,
and I have 134.7.0.0.
Now, which of these would have the longest prefix?
Well, it's the bottom two,
because they're the most specific.
These are the ones that are most specific
because they have the first two octets specified,
whereas the first one, with the 125.0.0.0,
only has the first octet specified,
so it is the least specific.
So if I'm dealing with something like 10.1.1.0/24
that is really, really specific,
because I have the first three octets specified,
the 10.1.1.
That means I only have 256 possible IPs left
because of that .0 at the end.
Now instead, if I use something like 10.0.0.0/8
this means I only have one octet specified,
and the other three are really wild cards.
So I can have up to 16 million IP addresses
because of those three sets of zeros.
So you can see here the longer the prefects we have
or the higher the CIDR notation,
the more specific that route becomes.
Now when we look at these routing tables
and we look at all the routes in the table,
those routes are going to tell us
what the destination network is
and which router it should go to to get to that network.
It'll also tell us which port on the router
is going to be used to send traffic out
and the cost of that route,
which is basically like switching,
where it's dependent upon numbers of different factors
like the link speed and other factors like that.
Now we're going to talk specifically
about those different factors in another lecture
when we start diving into routing protocols,
but for now, just realize that every link in a route
does have a cost associated with it.
So what are some of the sources
of routing information that we can have?
Well, there are really three different sources
that routers are going to use.
The first one is called a directly connected route.
Now, a directly connected route
is learned by a physical connection between two routers.
So, if you look on the screen here,
I have three different routers,
router 1, router 2, and router 3.
Now, router 2 knows where router 1 is
and router 3 are
because it has direct cabling between those.
And this is shown by those zigzag lines,
or that lightning bolt looking line,
that's here on my diagram.
This denotes that it is a serial connection.
Next, we have static routes,
and this is the second way that routers know
how things are connected to them.
Now, a static route are routes that are configured
by an administrator manually.
So, for example, router 1 knows how to get to router 2
because it's directly connected,
but it doesn't know how to get to router 3 yet.
So for me to tell it how to get to router 3,
I can put a route into my routing table
that says every time you want to send something
to router 3,
just go ahead and send it through router 2.
That would become a static route.
Now, there is always one default static route
in every router, and it's a special one.
It's known as 0.0.0.0/0.
Basically it says to the router,
if you don't know where to go, just go here.
It's kind of like your default gateway.
And so for router 1, it might have a default route
of 0.0.0.0/0 that says, go to router 2
anytime you don't know how to get someplace.
And then it becomes router 2's problem
to figure out what to do with that traffic.
Now, the third way that routers can do this
is by using what's known as dynamic routing.
And this is done by using dynamic routing protocols.
These protocols are learned by exchanging information
between routers automatically based on the protocols.
Now, instead of me having to go into router 1
and tell it how to get to router 3,
instead, I can just let router 2 do it.
Now the idea here is that when router 1
and router 2 become directly connected,
they start sharing their routing tables.
So router 1 is going to say,
"Hey, router 2, do you know how to talk to some people?"
And router 2 will say, "Oh yeah,
"I'm connected to router 3.
"So anytime you got something for router 3,
"just send it to me and I'll pass it on for you."
And they do this all by themself automatically
using these dynamic routing protocols.
This is really great, especially in large networks,
because we don't have to manually configure everything.
So, for example, think about if I took your router at home
and I had to put down every single route for you
to be able to find every website
you wanted to get to on the internet,
you would not be able to do it.
It was just too many things out there, right?
So instead, we use dynamic routing to accomplish this.
When you connect to the internet, you connect to your ISP,
and they know that they are now your default route.
Anything you want to get to that's not inside your network,
you send it to your ISP,
and then your ISP will send it to the next router,
and it keeps going up that chain that way.
So that's a great overview
of the three different types of routes.
We have directly connected routes,
static routes, and dynamic routes.
So, let's go ahead and dig a little bit deeper
into each of these three types
so you can understand them a little bit more.
First, let's take a look at a directly connected route.
When we look at a directly connected route,
it's going to look something like
what you see here on my screen.
Now, as you can see, router 1 and router 2
are directly connected with that zigzag line.
That's that serial connection.
Now, these routers both know how to get
to the other switches
because they're directly connected to them, right?
So if I look at router 1's table,
it says I'm to 10.0.1.0/24,
which is the network that it owns on switch one.
It's also connected to 192.1.1.0,
because this is the serial connection
between the two routers.
Now, notice that router 1 does not know how to get
to the 10.0.2.0 network,
because this is on switch two,
and that's hanging off of router 2.
It has no information on this
because it only knows things that are directly cabled to it.
Now, if we go further into static routing,
I can actually write that down as part of my default route,
or 0.0.0.0 for router 1.
Now this tells me that anytime I don't know an IP address,
I'm simply going to send it out port serial 1/1,
which is going to push it over to router 2.
And so in this case, if PC1 tries to get to PC2,
it would get as far as router 1,
and then router 1's going to say,
"Ugh, I don't know how to get to 10.0.2.2,
but maybe router 2 does,
and it's going to push that over to them
over that wide area network connection,
that serial connection that's directly connected.
That's how this manual configuration works
with a static route. All right, so I think you understand
how direct connections work and how static routing works.
Let's take a look at the dynamic routing protocols instead.
Now, dynamic routing protocols can have more than one route
for an existing network.
If I have a more complex network diagram,
like these five routers that you see here,
and I wanted to get from one to five,
I can go a couple of different ways.
I can go one, two, three, four, five.
And I really just start zigzagging all over the network.
Or I might go one, two, four, five,
or I might go one, three, four, five.
There's lots of different ways for me to go,
because all the different connections that are there.
So how does my router know which one is best?
Well, the dynamic routing is going to get negotiated for us
based on the number of hops that are there,
which is the number of times I have to go
through a different router,
the number of link bandwidth that's available,
so how fast it is.
I might go through the ones that are faster or slower.
And other criteria that are out there.
All of these dynamic routing protocols
can be able to be supported
depending on what routers you're using
and different criteria of how you want to set 'em up,
depending on how we configure them.
Now we're going to spend an entire lesson
on the different types of dynamic routing protocols,
so we can really dig into each of them
and you can really understand,
because you're going to get test questions on them,
come test day.
Now the last thing I want to talk about in this lesson
is preventing routing loops.
Just like we had an issue with switches
where you can get loops and broadcast storms,
you can get issues with routing
if things start going into a circular manner,
things will just end up getting lost in cyberspace, right?
So, to prevent that,
we have two different techniques we can use.
These are known as the Split Horizon and the Poison Reverse.
Now, with a Split Horizon, this is going to prevent a route
that's learned on one interface
from being advertised back out that same interface.
So, in this example, you see router 1
knows how to get to router 2
because of that direct connection
between those two routers.
Now, it's not going to go and tell router 2
how to get to router 2 based on that same connection.
Because guess what?
It came in that connection,
so it can't go out the same connection.
This is essentially what our spanning tree protocol
did for us in our switching networks.
But now we can do this inside of routing.
Now, the second way we do this
is what's known as a Poison Reverse.
And a Poison Reverse is going to cause a route
that's received on one interface
to be advertised back out that same interface,
but with a really, really high cost
so that nobody would ever want to use it.
Now these are just two different techniques
for you to stop routing loops.
You could use one or the other,
it really doesn't make a difference,
as long as you're using one
that's going to prevent that routing loop for you.
The first one is I'm just not going to repeat anything.
The second one is I'm going to repeat it,
but I'm going to tell you it's so expensive
that you'll never ever want to use it.
So, let's go ahead and take a look
at an example of these routing loops
and how we can make sure we prevent them.
So, here's a network with no issues at all.
I have three routers here.
I have router 1, router 2, and router 3.
You can see the different networks based on the IPs
and the routing tables are shown here on the screen.
Now we're going to look specifically at the routing tables
for router 2 and router 3 in this example.
Now, if I started having an issue, like for instance,
the network connection from router 3
for the 10.1.4.0 network went down
because ethernet 0/1 went down.
What do you think's going to happen?
Well, router 2 still thinks it can get to that network,
because it says, "Hey,
"I can get there through my serial port of 0/1.
because I have a connection to router 3.
Now, if router 3 went down, it's going to say,
"I don't know how to get there anymore."
And so it's going to ask its friends
using the dynamic router protocols.
And so at this point it's going to say,
"Hey, router 2, do you know how to get to that network?"
And what happens is router 2 would say,
"Oh yeah, I know how to get to that network.
"I can do it in just one hop.
"So go ahead and send it to me."
And then router 3 says, "Oh great,
"that means I know how to get there, too,
"because I'm connected to you, router 2,
"and you know how to do it.
"So that one hop for you becomes two hops for me."
And it keeps going back and forth.
And then router 2 goes, "Oh, I know how to get there.
"Router 3 knows how to get there.
"And he says he can do it in two hops,
"so I can do it in three hops."
And it keeps going back and forth until both of those
get to be such a high number that neither of those routers
can actually ever get to that route anymore.
Now, this is the idea of what a Poison Reverse would do,
but when you use a Poison Reverse,
instead of making it go one at a time and keep iterating up,
it would immediately just say,
"Hey, I know how to get there,
"and it would take me a thousand hops.
"And so if that's such a huge cost,
"you won't want to send it to me."
That's the way that router 3 can say,
"I don't have this route anymore."
Now, if you don't use Poison Reverse
and you don't use Split Horizon,
what ends up happening is you have this loop that happens,
and two says, I can do it in one,
three says I can do it in two,
two says I can do it in three,
and they keep counting up,
and that eats up a lot of your resources
in your network by causing this loop
and those two sending packets back and forth to each other,
continually increasing that cost
until it gets so high that they stop sending traffic.
Now, if there's no other way to get to that network,
it's just going to keep going in this infinite loop,
and that's going to cause a real problem for you.
This is why it's really important
to make sure you're setting up your Poison Reverse
or your Split Horizons.