Join Mike Meyers for an in-depth discussion in this video Introducing routers, part of CompTIA Network+ (N10-006) Cert Prep: 3 The World of TCP/IP.
- Now, I've got myself a little network right here, running TCP/IP. I've got four computers all connected to this switch. Now, because it's TCP/IP, I had to give all of these computers because they're all on the same broadcast domain, a network ID, in this particular case it's 232.25.201 WAC 24. So, all of the computers on this network, I can have up to 254 hosts, are going to have to start with 232.25.201.
Now that's fantastic, but what if I want to connect to other networks? What if there is another set of computers on the other side of the hall or the other side of the world, and it has it's own network ID and we want to interconnect to it. Well, in order to do that, (laughs) maybe if we had really long cables, but what we need to do is use a very special device called a router. A router is nothing more than a box that is designed to interconnect network IDs. Routers filter and forward based on IP address.
Remember, switches filter and forward based on MAC address, but routers filter and forward based on IP address. Now, we've all seen routers. You've probably got something like this sitting around in your house and just most of us do. Now the problem with these, we call these routers and that's just a term I've got to get used to. Most of these devices are routers, but they're also built in switches, and built in wireless access points, and built in all kinds of other stuff. Now if you really want to see a router, now this is a router.
Now this, this is an old, old router but I love it so much. This is an old Cisco 2811. Routers can have lots and lots of connections on them. In order for a router to function, it's going to have to have at least two connections, remember what a router does, it interconnects network IDs. It basically interconnects between the two different network IDs. But it can have more than that. So to understand how routers really work, the best thing we can do right now is head over to my cool little pseudo router place, and let's do a little diagram.
Let's pretend for a moment that this little box here is a router. Now, this router's going to have two connections, so let me put two connections in here. In this case we'll say they're ethernet, although routers really don't care. But we'll say I've got two ethernet connections. Now, this one right here is connected to the 192.168.15 network. And this one here is connected to the 232.25.201 network. So, let me show you how that looks. So, on one side here we've got the 192.168.15 network, so everything in here is going to be 192.168.15 something.
Everybody's plugged in to this switch. On the other side, we have the 232.25.201 network, everybody's going to have a 232.25.201, and everybody's plugged into their switch. To interconnect these, what we do is we put a router in between them, and we run a cable from one port on the router to each of the switches on the different network IDs. Now, in order to make these guys part of these networks, these guys have to have IP addresses. So in this case, we'll say this one is going to be 192.168.15.1, and here we'll say this connection is going to be 22.214.171.124.
Every router has some way for you to give these ports an IP address. So for example, on a home router, here you can see where I'm just typing in an IP address. On a more advanced router it can be a bit hairier. And while all these commands look strange trust me, I'm giving one of the ports an IP address. So, lets watch routing in action. So here comes a packet. So this packet's coming in, it's heading over to 192.168.15.30.
But it's from the 126.96.36.199. Now first of all you'll notice that all the ethernet stuff has been stripped away. Routers don't care about ethernet. Any way it comes in, it just strips it away. The second thing the routers don't care about, is what port anything comes in. All it does, is it reads this first piece of information. That first piece of information says it needs to go to 192.168.15.30. But how does he know how to get there? It knows, because built into every router is what we call a Routing Table.
Now, lets look at this one up close so we can really see it. Now when we talk about a routing table, we're going to have at least four columns. The first one the address says, now you'll look in this particular case, on the first line it says 192.168.15.0, that's zero, and that's why you can't have zero in an IP address, because it's used by routers. It's identifying anything that says, that is 192.268.15 network with a WAC 24 subnet. Now those four zeroes in the gateway? That means this router is directly connected to that network.
Send it out on interface, whatever that might be. So if we take a look at this particular example here, and we read that first line it's going to say anything for the 192.168.15 network on a WAC 24 subnet, you're directly connected. Send it out this interface. Now, the second one right here just has to do with pointing stuff this direction. So, if anything is for the 232.25.201 network on the WAC 24, all zeros means you're directly connected to that network, send it out on that interface.
So that's the most basic routing table. All routers have routing tables and for most routers, the basic routing table is configured automatically. When you type an IP address into one of the ports on the router, it will assume that it has that route. So, these things pretty much generate auto-magically for us. There's some exceptions to that, we'll get into that in other episodes. Now, the example I just showed you is great, except for one big problem, and that is, there's a lot more than just two network IDs in the universe. So, if there are only two networks IDs life would be great, but the internet itself is composed of probably tens of millions of network IDs, and you never know who wants to connect to what.
So we have to come up with a mechanism that allows our router to connect upstream in essence, in to the cloud, if necessary. And that's actually fairly easy to do. What we do, is that we have built in to every router something called a Default Route. Now to watch how default routes work, what I want to do is take the analogy we made a moment ago and let's stretch it out a bit. So here's our two network IDs. But let's change this a little bit. First of all, we're going to go ahead and keep our 192.168.15 network.
That's going to be our local network here at the office, or here at home, or whatever it might be. But, we're going to change the 232.25.201 network. What that's going to be now is actually coming from our internet service provider. So our internet service provider has what we would call an Upstream Router. And his address, because he's part of that network ID also, is going to be 188.8.131.52. So we are .1, but maybe the customer next door is .2, and another customer is .3, and somebody else is .100.
So this entire 232.25.201 network doesn't have any computers on it at all. It's just a bunch of routers. And what's what makes the internet beautiful. Now, what's interesting to us, is how do we know that the upstream router's IP address is 184.108.40.206? Almost every router in existence has some methodology for you to go in and query what it's upstream router is, or sometimes called the default gateway. So here's an example right here on my little home router.
So to take advantage of this default route, we're going to update the routing table. So now it's going to look something like this. So what he have now is a default route. The default route basically means if it doesn't meet any other criteria if it doesn't know where to send it, always send it here. Default routes are really obvious. It's always going to start with an address of all zeroes, which means I don't care what the address is, all zeroes for the subnet, I don't care what the subnet is send it out on this interface, but send it directly to the next gateway up, 220.127.116.11.
Now you've got to be careful about this because a lot of people get confused the first time you see a default route. In particular, it seems that we have 18.104.22.168 being an interface for two different things. Let's go ahead and get the routing table up here on the screen. So if you look, actually there are two different routes where we send it out 22.214.171.124. Let's make sure you understand the difference. This is important. So, for example, if I get a packet that needs to go to 126.96.36.199 say.
What's going to happen is the router is going to look at that routing table and because it sees that the gateway is all zeroes, that tells the router that it is directly connected to 188.8.131.52. So your router knows because the gateway is zero, it can ARP that system. So your router will go out on interface 184.108.40.206 and say "Hey! 220.127.116.11! What's your MAC address?" He ARPs him.
That device responds back, the router can now put on the ethernet information, and shoots it out 18.104.22.168 and that computer gets the packet. However, let's change it up a little bit. Let's say that your router gets a packet for 22.214.171.124. Now, obviously the only route that's going to work in this case is the default route. So what your router does is that it goes at the address all zeroes, doesn't care what the address is, subnet, all zeroes, doesn't care what the subnet is. However, things change a little bit here.
Yes, it will send that packet out on 126.96.36.199, but what it's going to do is it's going to ARP the gateway. So it's going to send out an ARP to 188.8.131.52 because that's what's in the routing table, and it'll say "Hey! What's your MAC address?" That upstream router is going to respond, sends him his MAC address, now it knows how to send it, and it shoots it up to the router. Isn't that absolutely cool? So many people get blown away by routers, because they think of routers as doing all these changes, routers almost really never change the IP packet, well there's a few exceptions where they do, but in general, the only thing routers do is read the destination IP address and then they change the MAC address depending on where they want to send it to.
Pretty cool, huh? Well, there's one problem here. And the problem is that the router I've shown you so far only has two connections. We have one that's to our local area network, then one that's upstream to our ISP. You see this a lot on these home routers. In fact they'll call it a LAN address and a WAN address. But routers are a lot more than that. When you only have two connections that router isn't really routing, it's just acting kind of like a gateway, as an entry way for you to get to the internet. In fact we tend to call these types of routers Gateway Routers for that reason.
But they can do a lot more. In my office, we have a much more industrial router. And my router has three connections. The reason it has three connections is because I have two ISPs. I have one ISP that goes through my commercial cable account, and then I have another ISP that uses DSL. The reason I do that is because I don't want to ever go out, and if one goes down, I automatically want to be able to use the other. And this is where routers really, really get powerful. In order to show you all this coolness, let's first of all do a quick diagram.
So let's add to our diagram. Now, we still have our 192.168.15 network, that's our local area network. But we're going to say the 232.25.201 is our commercial cable connection, and now we're going to add a third connection. In this case, it's going to be 75.29.6 network, and that's going to be my DSL connection. So, we're going to have to do a few things. First of all, we're still going to have to give that third interface an IP address, and we're going to go ahead and give it a 184.108.40.206, and it's connected upstream to 220.127.116.11, so let's see how all this works on our router.
So to make this work, the first thing that we're going to have to do is add this third connection. And on more advanced routers, it's really easy to buy an extra ethernet connection, you just screw it in. Now, to make this work in terms of a routing table it's going to have to look something like this. Now first of all, you'll see that I got my 75.29.6, so just as a reminder, this is my local area network connection. This is my connection to my commercial cable, and this is my connection to my commercial DSL. So I've got a local connection in here for the 75.29.6, everything's great there.
But you'll notice what I've done here, is I have in essence, two default routes. So, how does my computer know? If I've got two default routes, which one am I going to use? And that's where this comes in to play. What we call the Metric. The metric is a relative value that gives your router an idea if it has more than one choice to do something, which way does it go? Now I prefer to use my commercial cable connection, because it's faster than my DSL, so you'll notice that I've given that a lower metric value than my DSL.
If my router has something to send out on the default route, it's going to use this one first. However, if this connection goes down or something like that, then he can go ahead and auto-magically switch over to the secondary default route, and he uses that metric to make that decision. Now this is just the basics of routing. We're going to be going in to a lot more routing in other episodes. But at this point, what I'm trying to do is get you started on the concept of what routing does for us.
Just to wrap a few things up though, I want to make sure you understand this. Number one, routers don't care where a packet came from. Only where it's going. The other thing I want you to remember is that routers are not tied to ethernet. Now in these examples, I've said we had two or three ethernet connections, but for a router it can have a DSL connection, it can have a doses connection, it can have optical, it can have all kinds of different connections and it simply doesn't care.
The reason it doesn't care is because routers only care about the IP packet. And in most cases, that IP packet never changes. (upbeat piano music)
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.
Skill Level Intermediate
Q: This course was updated on 06/20/2017. What changed?
A: The following topic was updated: subnetting with CIDR.