Friday, December 4, 2015

Week 13: Day 036 - Routing #1


Hello once again! Today we're starting a new chapter on routing. We'll be covering a lot of stuff about how routers work, including NAT, I'm not going to tell you what the acronym represents until later, cause we'll find out soon enough. Let's get right in!

Firstly, as we all know a router is hardware that forwards packets. Because of this, routers are classified in the Network layer of the OSI model, and the Internet layer of the TCP/IP model. Routers generally have at least two connections, but they can contain way more connections than that. In an office you may find the Cisco 2600 series device, which is one of the most popular routers ever made. Although it might be an old router, it's durable, and reliable. Cisco just has a way of doing that! One port within these routers leads to one network, while the other connection (port) leads to another. The router reads the IP addresses of the packets and determines where it should send the packets.
The majority of techs nowadays deal with home routers which are meant to connect to DSL or cable modems. The typical router will combine the router and the switch, while also providing DHCP and a firewall. Routers are great! The LAN side of say for example, a Linksys home router will connect immediately to the built-in switch. Because of this, it's not necessary to connect multiple computers into a separate switch which you would have had to buy to connect it to the the cable modem or DSL receiver. Some would look at the said router, and think that since it may have for example, 6 ports, that it would connect to 6 different networks. In reality, it can really only connect two networks. Yhe extra physical ports are part of the built-in switch. All routers will examine packets and send them to their destination, so let's see how!

Routing starts with packets which go to the router awaiting further transport.  Basically, the router will discard any information from Layer 2 and will drop the IP packet which was inside it, into a queue. The router doesn't discriminate, so it doesn't give a crap where the packet came from. It just unpacks the packets and drops it into a queue. The router then reads each packet's destination IP then sends it straight there, through the correct port. To perform such an inspection, the router has a something called a "routing table" which tells the router where it should send packets. As we established before, the router has two ports internally, one which connects to your ISP. This is called WAN in the routing table. Then there is another four ports which is the built in switch, and that's connect to LAN. Here is an example of a routing table:

Each row defines a single route. Each column specifies criteria. Here's the meaning of the columns that you see above, according to my textbook.

- Destination LAN IP: A defined network ID. Every network ID directly connected to one of the router's ports is always listed here.
- Subnet Mask: To define a network ID, you need a subnet mask
- Gatway: The IP address for the next hop router; in other words, wher ethe packet should go. I fhte outgoing packet is for a network ID that's not directly connected to teh router, the Gateway column tells the router the IP address of a router to which to send this packet. That router then handles the packet and your router is done. If the network ID is directly connected, then you don't need a gateway. Based on what's needed, this is set to 0.0.0.0 or to the IP address of the directly connected port.
- Interface: Tells the router which of its ports to use. On this router, it uses the terms "LAN" and "WAN". Other routing tables use the port's IP address or osme other type of abbreviation. Cisco routers, for example use f0/0, f0/1 and so on.

The router looks at its destination IP, then proceeds to consult the routing table to see which device will receive the packets. Some routers read the table top-down and some bottom-up. One trick when reading a routing table is to think, every zero you use means "anything". Like if you saw the IP 10.12.14.0, compare that to subnet mask 255.255.255.0 you'll see that it's a /24 network ID and that any number between 1-254 for the last value will work. Continuing, every router has a default route. For example, it may forward it to 76.30.4.1 by default, through the WAN port. It's important to have a default route cause it's a guide for the router with what it may do when it receives an incoming packet. Sometimes though, if you decide to add another line to the routing table, it will give another route. One important thing to note is that not only Routers use routing tables. You'll find them on just about every device which is connected to the network. You might ask why they have them. It's because the NICs and the other devices need to know the IPs coming in and going out. Here's what a routing table looks for Windows:


Not much different than a home router, it just usually has a lot more routes. The interface has an actual  IP, and a loopback, instead of LAN protocol. In the world of routing there is something called "metric", this is part of the beauty of routing because a metric is a value which defines the cost of using a certain route. Lowest routes always win. The router will always use a metric of 1 unless it stopped working for some reason. If it were to stop work it would switch to the 10 metric. That's basically how the internet works if you think about it. A bunch of routers connected to even bigger, more powerful routers. Connections will go up and down all the time , so routers are constantly talking to each other. Let's try to make out what the routing table is saying. The bottom line defines default IP broadcast (it doesn't matter whether the default ip starts bottom or top). The next line up is the multicast address range. The next route say sthat any adress in the 147.100/16 network ID are part of the LAN. If your computer DHCP client isn't receiving an IP address, this route would enable you to communicate with outer computers on the network which may have the same problem. The next line is a loopback, and the line after that is the directed broadcast. The next line means anything addressed to the machine goes to the loopback. Then the one after that defines the local connection. Another note, local connections do not use default gateway, but every routing table still has a gateway column. This is because Microsoft had to put something there, so they just put the IP address of the NIC. In Windows 7 and I assume further, the gateway value for local connections says "on-link". FINALLY, the top line deifnes the default route. On Windows use PuTTY and then type the command "show ip route" and it's pretty self-explanatory what it does. The last three lines will be the routing table. That's basically how you look at routing table, and actually understand it. In the end what they basically do is list the routes so the IP packets can be moved to the correct interface. On that note, thanks for reading, and until next time!

1 comment:

  1. As we discussed, feel free to spend less time blogging (though I would recommend using you blog as a "technical journal" to specifically record things you need to remember) and more time preparing for the exam. End of 2nd quarter is the goal, and we will be half way through the 2nd quarter by the end of next week.

    ReplyDelete