Static Routing
So far we have discussed the basics of how routing protocols route traffic through the network, but there is another way to route traffic and that's static routing. Instead of having a routing protocol determine how traffic will be sent we can actually go in and tell a router where it should send data that is destined for certain devices. Static routing is an extremely useful tool that can be used to get almost any network up and running. Static routing doesn't require the router to maintain any additional databases aside from the routing table, and doesn't require the router to calculate routes or maintain neighbors which frees up the routers CPU. The disadvantage to static routing is the amount of work required to maintain it in larger networks. If a router were added to a larger network it would take a lot of work to add static routes to all routers in the network to the new router.
Let's take a look at how it's done. The following image shows a small network -
Let's take a look at how it's done. The following image shows a small network -
When this network is configured with IP addresses they will only know about directly connected routes. In this network R1 and R3 both know R2 but not about each other. So if R1 wanted to send information to R3 it wouldn't know where to send it so we would have to set up a static route telling R1 where to send data in order to get to R3. We do this with the 'ip route' command.
The first step is to add the network that we are routing to which in this case for router 1 is the 192.168.2.0 network. We then tell the router what subnet on this network to route, and in this case we are routing for the entire 192.168.2.0 network. The final piece of information we have to give the router is where to send traffic for this network. There are a couple of ways to do this, you can either tell the router the next hop IP address, or the exit interface. I chose the next hop IP but either will work. In our network the next hop IP is the IP address of the interface on router 2 that is connected to router 1. We could have put the exit interface of serial0/0 as well since this is the interface that router 1 has to send traffic out of in order to get to router 3.
Ok now that we have our route in place we should have connectivity.
Ok now that we have our route in place we should have connectivity.
So what went wrong with our ping? Well router 1 is sending an ICMP echo request to router 3, which router 3 will receive just fine, however router 3 doesn't know where to send the echo back to since we haven't added a static route to router 3. When router 3 receives the ICMP packet it will check the source IP address and then look at its routing table, when no entry matches the network of the source router 3 will simply drop the packet. Let's fix this problem -
Once the static route has been added to router 3 we can see that the ping is successful.
Default Route
When a default route is configured in a router it will enable the router to send data from unknown sources to the default route. This is useful when a network only has one way out of it such as a network that is connected to the internet. Let's take a look at the following network -
Let's assume that R1 represents the internet and R2 is the router connected to the internet. Routers 3, 4, and 5 are only connected to the shared LAN segment and to hosts. We could configure a default route to routers 3, 4, and 5, telling them that if they do not know how to get to a destination then they should send the data to router 2. We can configure a default route by issuing the 'ip route 0.0.0.0 0.0.0.0 next-hop IP or exit interface' command. This command tells the router that if it doesn't know how to get to a destination simply send it out the defined exit interface or to the next hop IP. There is one other command that must go along with this command and that is the 'ip classless' command which tells IP to check the routing table for a default route instead of discarding the packet. This is needed in case a route is in the same classful network but has a different subnet mask.