From the course: CompTIA Network+ (N10-009) Cert Prep

Introduction to routers

- 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 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 could 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 its own network ID and we want to interconnect to it? Well, in order to do that, 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 have 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 'em. 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 into 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. 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's going to be 232.25.201.1. 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 let's 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 232.25.201.191. Now first of all, you'll notice that all the ethernet stuff has been stripped away. Routers don't care about ethernet. Anywhere it comes in, it just strips it away. The second thing that 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 let's 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 'cause it's used by routers. It's identifying anything that says that is 192.168.15 network with a WAC 24 subnet, now those four zeros 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 now, 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, it just has to do with pointing stuff this direction. So if anything's for the 232.25.201 network on a 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 automagically for us. There's some exceptions of that and 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 network 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, into the cloud if necessary. And that's actually fairly easy to do. What we do is we have built into 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, 'cause he's part of that network ID also, is going to be 232.25.201.11. 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 that'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 232.25.201.11? Almost every router in existence has some methodology for you to go in and query what its 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 we 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 zeros, which means I don't care what the address is, all zeros 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, 232.25.201.11. Now you 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 232.25.201.1 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 at, actually, there are two different routes where we send it out, 232.25.201.1. Let's make sure you understand the difference. This is important. So for example, if I get a packet that needs to go to 232.25.201.66 say, what's going to happen is the router's going to look at that routing table, and because it sees that the gateway is all zeros, that tells the router that it is directly connected to 232.25.201.66. So your router knows, because the gateway is zero, it can ARP that system. So your router will go out on interface 232.25.201.1 and say, "Hey, 232.25.201.66, 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, 232.25.201.1, 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 3.4.5.6. Now, obviously the only route that's going to work in this case is a 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 232.25.201.1, 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 232.25.201.11 'cause that's what's in the routing table. And it'll say, "Hey, what's your Mac address?" That upstream router's 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 really almost 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, is that the router I've shown you so far only has two connections. We have one that's to our local area network, and then one that's upstream to our ISP. You see this a lot on these home routers and in fact, they'll call it like 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 a entryway 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 75.29.6.144, and it's connected upstream to 75.29.6.1. So let's see how all this works on our router. So to make this work, the first thing I'm going to have to do is add this third connection. And on more advanced routers, it's really easy to buy a 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 into 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 'cause 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 automagically 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 into 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 DOCSIS 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.

Contents