Join Mike Meyers for an in-depth discussion in this video Introducing routers, part of CompTIA Network+ Exam Prep (N10-006) Part 3: The World of TCP/IP.
- View Offline
- Hi. I'm a router this time. Now what I wanna do is give you an understanding of how routers work. This is gonna be pretty basic, but it's exactly how routers actually do the voodoo they do so well. Now to do this, what I've got is I've got three ports coming into this particular router. Now what's interesting here, if you remember from other episodes, when we used this analogy for switches or something, we would just say Port 1, Port 2, Port 3, or something like that. Routers actually have IP addresses assigned to all of their ports.
So this is very important. A switch doesn't care about IP addresses. A hub doesn't care about IP addresses. But routers do. So just like you can assign an IP address to your network cards in your computer, you assign IP addresses to all of the router ports on a router. So, what's gonna happen here is that we're going to have a piece of data come in. So here comes a chunk of data. Now what I need you to appreciate is as soon as the data comes in, the router strips off the Ethernet portion of it, and only looks at the IP stuff.
And this is where all the information comes from. We've got an IP source and an IP destination in here. Routers look at the IP destination. Notice that routers don't care what port this came in on. They don't necessarily care too much about order, although a lot of them try to do what's called FIFO, first in first out. However, they do look at that destination, 'cause it's trying to figure out where to send this. To figure out where to send it, it uses something like this. This is a routing table, and built into every router on earth is a routing table.
This routing table is created statically by the person setting up the router. So, what I wanna do is take a look at this. First of all, you're gonna see that there are four columns: Address, Subnet, Gateway, and Interface. That's important, but far more important is the fact that there are four rows. Each one of these rows is what we call a route. Now to appreciate what's going on here, I'm gonna give you the big picture of how all of this is working. This red triangle is gonna be the router. And right now it's only got one connection.
We're gonna have to put two more in here. So the first thing I want you to appreciate is that it's directly connected-- this is a switch right here with some computers. It's directly connected to the 192.168.15 network ID. Alright? In fact, that's why we gave it one of these. This is all 192.168.15. So my problem here is that I don't want to keep drawing all the switches and individual computers. So what I'd rather do is something like this.
So I'm gonna use this little half moon to represent all the switches and all the computers. This little half moon is the entire 192.168.15 network, okay? Now if you're okay with that, we can extend this a little bit. Now let's take a look back down here on the router for a minute. So we've got another connection on the router called 172.17.3.1 so let's put that on here. 172.17.3.1 is a connection to another group of computers.
There's another switch here, and they're all there ready to go. Now, if we look one more time, we'll see another connection with 184.108.40.206. That one's a little bit different than the other two. In this case, I'm actually gonna add another router. So if we take a look at this picture here, we'll see that this router right here has three different IP addresses. And we'll see these again on the close-up. But the important thing to appreciate here-- in fact, I'm gonna sneak this in a little bit on the close-up.
And you'll see that this router is connected on 220.127.116.11 to another router. And this is what we would call the upstream router. This is probably this router's internet connection, and it's 18.104.22.168. So these guys are part of the same network ID. There's actually a switch in here and stuff like that too. Although router network IDs often are just two routers connected together. So this is basically the setup that we have. Now, understanding this setup, let's go look at the routing table one more time.
So if we take a look here, first of all, anything from 192.168.15.0-- Do you see that zero right there? That's one of the reasons you can't have an all zero IP address. It's because it's reserved for routing tables. So any traffic that's for the 192.168.15 network on a WAP 24 subnet, do not use a Gateway. The Gateway means you are not directly connected to it. Here's a router address. Because it's all zeros, it tells me, "You're directly connected. Just start arping. "You're ready to go." And send it out on 192.168.15.1.
If this piece of data is for 192.168.15.27, by reading the routing table, I know that I can go ahead, do an arp, because I've got all zeros on the Gateway. There is no other router. I'm directly connected. You can always arp within your own broadcast domain. So I'm gonna go ahead and arp, get the Ethernet address for whoever that IP address is, and all I need to do then is send it out on the Interface as specified right there.
Tada. You have just sent out your first IP packet. Now there's something I want you to appreciate here that's kind of important. I've gotta get my packet back. What always trips people out the first time they see routers is that they think something strange is happening here. So the first thing is is that the packets come--sorry. The frames come in and whatever Ethernet or DOS is or DSL or whatever it is, Layer 2 stuff is ripped off.
So now we've got this IP packet right here. The IP packet is red in terms of its destination IP address, but the only thing a router really does-- he doesn't do anything to the IP packet. All he does, and assuming that these three connectors are all Ethernet, is he goes out and arps to figure out where to send this guy to and puts whatever the Layer 2 data is necessary and sends it out the right pipe. Routers read the IP information, and they use that as a gauge as to figure out which pipe to send it back out.
But the IP packet itself is never molested. There's a few situations where it is. But for the most part, it's left alone, and it's getting sent out. So let's go through the rest of this routing tape. The other two are pretty straightforward. Anything for the 98.201.164 network, notice that it's a WAP 23 subnet, which is kinda cool. And there is no Gateway. Send it out on 22.214.171.124. Send it out on this port. To appreciate what's going on here, it's saying anything from the 98.201.164 network, go ahead and send it out here on 126.96.36.199.
What it's saying is if you've got anything for that address send it here. Thing is for just two routers, the chances of there actually being any switches or computers in there are pretty much zero, so that's a route that's probably not gonna be used too much. The next one is pretty much identical to the first one. 172.17.3.0 on a WAP 24. There is no Gateway. Send it out on 172.17.3.1. Well that's great, because with those two routes alone, any data that's being sent between computers on this network ID know how to get to this network ID and vice versa without any problems.
It's the last one that's kinda cool though, and I want you to take a good hard look at this. The last route on here is what we call the default route. I don't care what the Address is. I don't care what the Subnet mask is. Send it out to 188.8.131.52. It says go find another router. And to get to that router, send it out on 184.108.40.206. Take a look one more time.
So there's more connections on the far end of this router. So if you wanna send stuff out that way, send it to this guy but use that port. Default routes are critical. Every router that's gonna have some internet connection at least is going to have a default route. Keep in mind that your router will always use the best route to find on the information it's given. So, while the default route could work for any IP packet, if there's another route that works better, for example, 192.168.15 network, it's gonna go ahead and use that one.
Fantastic. Alright. Now what I wanna do is I wanna change the game here a little bit. The first thing I'm gonna do is I'm gonna get rid of this other small network. So what I'm gonna do right now is I'm gonna add another router. Now I want you to look at this for a minute.
What we've just done is we have in essence given my router right here-- Whoops. I thought there was something that didn't look right. He's not on the 172 network anymore. There's now a 202.190.44 network. What I've just done is I've created two different connections to the internet. Alright, so this is say my Comcast cable connection, and over here is my AT&T FIOS fiber connection. Who cares? The important thing is is that this router plugs into two different internet connections.
The whole function of a router is to get data to wherever it's supposed to be. However, it has another big job. And that is, if a connection dies, make a new route so that it can take advantage of it. So what we're gonna do with the router now is-- I wanna change things here a little bit. We're gonna update the routing table to reflect some new information. And I want you to take a good, close look at this. Now you'll see we still have the 192 network. Okay? And this is the local connection for the 98. That's great.
But what I want you to look at is right here. We now have two default routes. Do you see that? So these two columns are the criteria to determine it, and then here's what you do. So you have two routes, and they're in essence in conflict. So what we have to do is give the router a tool to be able to determine, well, which one do you want me to use? So what I've done is I'm gonna add a 5th column 'cause, well, I'm a 5th columnist. And what I'm going to do is I'm gonna use these values called the metric.
The smaller the metric value, the higher priority the connection. So even though I have two identical routes that will go to two different places, my router is always going to use the 98.201.164 connection because it has a lower metric value than the other one. Wow, well that is a quick and dirty description of how routers work. It's highly accurate, but it is somewhat simplified. Understand that all of this data, these routing tables and all this information is generated statically.
Someone has to go in and basically type all this information in. What I need you to do is watch the next few episodes as we develop the concept of routers, take a look at some real-life router situations, and appreciate that, while this is all accurate, it can get a lot fancier.
We are now a CompTIA Content Publishing Partner. As such, we are able to offer CompTIA exam vouchers at a 10% discount. For more information on how to obtain this discount, please download these PDF instructions.