Welcome to Jeremy’s IT Lab. This is a complete course for the CCNA, Cisco Certified Network Associate, exam. In this video we will cover static routing, a very important topic to understand for the CCNA exam. In the previous video we looked at the basics of routing: how routers decide where to forward packets. And we looked at two types of routes: Local routes and Connected routes. Those routes are automatically added to a router’s routing table when you configure an IP address on an interface. Local routes provide a route to the router’s own IP address, and Connected routes provide a route to the network the interface is connected to. However, if you want the router to be able to send traffic to destinations that aren’t directly connected to the router itself, Local and Connected routes aren’t enough. Today’s topic, static routes, enable routers to send packets to remote destinations, that aren’t directly connected to the router itself. Here’s what we’ll cover in this video. First we’ll briefly review connected and local routes, while looking at the rest of the network topology I introduced in the last video. Then I will introduce static routes, and how we can use them to instruct routers about how to forward packets. And of course we’ll see how to configure static routes in the CLI of Cisco routers. Unlike Connected and Local routes, static routes are not automatically added to the routing table and must be manually configured. Finally, I will also explain the concept of default routes. So, first up let’s review Connected and Local routes by configuring IP addresses on the routers and checking their routing tables. In the last video I showed R1, so for this video let’s start from R2. I configured IP addresses on G0/0 and G0/1 and enabled both interfaces. Remember, if an interface is disabled the connected and local routes for that interface won’t appear in the routing table. Now, before I show the routing table I want you to think about what routes there will be in the routing table. There should be one connected route and one local route per interface, so a total of four routes. Remember, these routes are added automatically when you configure IP addresses on router interfaces. So, what will the destination of each route be? Well, the connected routes are routes to the networks R2’s interfaces are connected to. So, there should be one route to 192.168.12.0/24 and one route to 24.0/24. And then the local routes are to the exact IP addresses configured on R2’s interfaces, so there should be a route to 192.168.12.2/32 and a route to 24.2/32. Okay, here are the routes. Note that, for the sake of space, I’m not showing all of the different codes listed at the top of the output. Remember, C means connected and L means local. Anyway, as expected R2 has two connected routes: one to 12.0/24 and one to 24.0/24. Also it has two local routes, one to 12.2/32 and one to 24.2/32. So, to summarize: R2 knows how to reach its own IP addresses and destinations in its connected networks, but it doesn’t know how to reach destinations in remote networks. By ‘remote’ networks, I mean networks not directly connected to R2. So, R2 knows how to reach destinations in the 192.168.12.0/24 and 24.0/24 networks, including its own IP addresses in those networks. But it doesn’t know how to reach any of the other networks in this topology. If R2 receives packets destined for hosts in these other networks, it will have to drop them. R2 doesn’t know where it should send them. And here’s R3’s configurations. 192.168.13.3/24 on its G0/0 interface and 34.3/24 on G0/1. So, which routes will it have in its routing table? As you should know by now, it has two Connected and two Local routes. So, like on R2, R3 knows how to reach its own IP addresses, those are the local routes, and destinations in its connected networks, those are the connected routes, but it doesn’t know how to reach destinations in remote networks. So, it knows how to reach 192.168.13.0/24, including its own IP of 13.3/32, and it also knows 34.0/24, including its own IP of 34.3/32. It doesn’t know how to reach any of the other networks, though. So, for example, if it receives a packet and the destination is PC4’s IP address, 192.168.4.10, R3 wouldn’t be able to forward the packet. It would have to drop it. And here’s R4’s configurations. Note that R4 has three interfaces in use, so how many routes will it have in its routing table? The answer is six, three Connected and three Local. Same as R2, R3, and also R1 which we looked at in the previous video, R4 knows how to reach its own IP addresses and destinations in its connected networks, but not how to reach destinations in remote networks. These are the networks it knows, and these are the ones it doesn’t. For example, if it receives a packet destined for PC4, 192.168.4.10, it has a route to 4.0/24, so it would be able to forward the packet to PC4. However, if it receives a packet destined for PC1, 192.168.1.10, it doesn’t have any routes that match that destination IP, so it would have to drop the packet. So, all of these routers have connected and local routes. Now let’s start looking at how we can configure them to allow PC1 and PC4 to communicate. Notice that I’ve colored the interface labels for each device, and also added interface names for PC1 and PC4. PC1 and PC4 are Linux hosts, and their default interface name is ‘eth0’, Ethernet0. These colors will make things easier to understand as I demonstrate how packets move through the network. So, first we are going to look at the concept of ‘default gateway’. End hosts like PC1 and PC4 can send packets directly to destinations in their connected network. PC1 is connected to 192.168.1.0/24, so it can directly communicate with other hosts in that network, and PC4 is connected to 4.0/24, so it can directly communicate with hosts in that network. However, to send packets to destinations outside of their local network, they must send the packets to their ‘default gateway’. Gateway is an old term for router, so it means ‘default router’. So, these are the configs on PC1 and PC4. In Linux, the interface configurations are stored in a text file that you can edit. On PC1 for example, there is the line ‘address 192.168.1.10/24’, which configures the IP address as 1.10 with a prefix length of /24. And below that is the default gateway configuration, ‘gateway 192.168.1.1’. So, to send packets to destinations outside of its local network, PC1 will send packets to R1. The default gateway configuration is also called a ‘default route’. Basically, it’s a route to 0.0.0.0/0. All netmask bits are set to 0, none of the bits in the address are fixed. 0.0.0.0/0 includes all addresses from 0.0.0.0 to 255.255.255.255. It’s a route that includes everything. Remember the concept of ‘most specific’ matching route in the previous video? Well, the default route is the ‘least specific’ route possible, because it includes all IP addresses. 0.0.0.0/0 includes over 4 billion IP addresses. On the other hand, a /32 route like a local route is the most specific route possible because it specifies only one IP address. For example 192.168.1.1/32 specifies only 1 IP address. So, the default route says ‘if there aren’t any more specific matches for this packet, don’t drop it. Send it via this route instead’. Later we’ll see how to configure a default route on a Cisco router and what it can be used for, but for now just understand how it works for end hosts like PC1 and PC4. End hosts usually have no need for any more specific routes. They just need to know: to send packets outside of my local network, I should send them to my default gateway. So, if PC1 wants to send a packet to PC4, the source IP address in the IP header is 192.168.1.10, PC1’s IP. And the destination IP is 4.10, PC4’s IP. Now here’s a major point: what will the source and destination MAC addresses be in the Ethernet header? This is where you can start to really understand the role of Layer 2 and Layer 3. At Layer 3, PC1 wants to send the packet to PC4, so the destination is PC4’s IP, 192.168.4.10. However it has to first forward this packet to its default gateway, R1. So, it will encapsulate the packet in a frame and the destination MAC will be R1 G0/2’s MAC address. Now, how does it know R1 G0/2’s MAC address? To learn it, PC1 will first send an ARP request to 192.168.1.1, R1 G0/2’s IP address. I will show this part of the process in more detail in the next part of the course, called ‘Life of a Packet’. To keep things a bit simpler in this video, let’s just assume each device already knows its neighbors’ MAC addresses, I won’t show all of the ARP exchanges. So, PC1 sent that frame to its default gateway, R1. When R1 receives the frame, it will de-encapsulate it, meaning it will remove the Layer 2 header and trailer, and look at the inside packet. It will then check the routing table for the most-specific matching route. It has to make a decision about what it will do with this packet. So, here is R1’s routing table at the moment, just Connected and Local routes. Do any of these routes match the destination IP of the packet? No, R1 has no matching routes in its routing table. So what will it do with the packet? It has no choice but to drop it. In its current state, R1 doesn’t know how to properly forward the packet. To forward it, R1 needs a route to the destination network, 192.168.4.0/24. Remember, routes are instructions. R1 needs a route to say: to send a packet to destinations in network 192.168.4.0/24, forward the packet to next hop Y. Now, we know the destination, the 4.0/24 network, but what should be the next hop? What is the next router in the path to the destination? Actually, there are two possible paths that packets from PC1 to PC4 can take. One is the path via R3. PC1 to R1 to R3 to R4 to PC4. The other path is the one via R2. PC1 to R1 to R2 to R4 to PC4. In this video we will use the path via R3, not the path via R2. So, we won’t actually use R2 much in this video. The reason I included R2 in the diagram is that I wanted to demonstrate that, if there are multiple paths to the destination, you can choose which one the routers should use. Now, it is possible to configure the routers to use these multiple paths differently. Instead of choosing one path, they can ‘load-balance’ between path 1 and 2. That means some packets will take path 1 and some will take path 2. Or they could, for example, use path 1 as the main path and path 2 as a backup path. You will learn about these techniques later in the course. In this video, we will only use path 1, the path via R3. Now, to ensure PC1 and PC4 can communicate with each other, it’s not just R1 that needs another route. Each router in the path needs two routes: a route to 192.168.1.0/24, PC1’s network, and a route to 4.0/24, PC4’s network. This ensures two-way reachability, which means that PC1 can send packets to PC4, and PC4 can send packets to PC1. If, for example, all routers had routes to 192.168.4.0/24, but not 1.0/24, PC1 would be able to send packets to PC4, but PC4’s replies wouldn’t be able to reach PC1. R4 would drop the reply because it would have no route that matches destination 192.168.1.10. So, we want two-way reachability. It’s worth noting that, routers don’t need routes to all networks in the path to the destination. For example, R1 doesn’t need a route to 192.168.34.0/24. It just needs to know: to send packets to 4.0/24, I should send the packets to R3. R3 will take care of the packets after that. And likewise, R4 doesn’t need a route to 192.168.13.0/24. R4 just needs to know: To send packets to 1.0/24, I should send the packets to R3. R3 will take care of the packets after that. Okay, continuing on: R1 already has a connected route to 1.0/24, and R4 already has a connected route to 4.0/24. However, the other routes must be manually configured, using static routes. Before we get into actually configuring static routes, let’s plan out the routes we will configure. Here’s a chart of the routes R1, R3, and R4 need to allow PC1 and PC4 to communicate with each other. In blue are R1 and R4’s connected routes, note I listed the next-hop as ‘connected’. Then, in red are the static routes we have to configure. I will show the answers, but before that I want you to pause the video and think about what the next hop IP address should be for each route. Now let’s check. For R1 to send a packet to the 4.0/24 network, what is the correct next-hop IP address? Remember, we’re using the path via R3 for this video, not the path via R2. The answer is 192.168.13.3, the IP address of R3’s G0/0 interface. R1 has a connected route to 192.168.13.0/24, so it knows how to reach 13.3. It can then use that IP address as a next-hop to send packets toward the 4.0/24 network. Okay next one, what next-hop IP should R3 use to send packets to the 192.168.1.0/24 network? The answer is 192.168.13.1, R1’s G0/0 interface. And how about 4.0/24? It should send packets to 192.168.34.4, R4’s G0/1 interface. Finally, what next hop should R4 use to send packets to the 1.0/24 network? The answer is 192.168.34.3, the IP address of R3’s G0/1 interface. Okay, we’ve planned the static routes we need to configure. To allow PC1 and PC4 to communicate with each other over the network, let’s configure these static routes on R1, R3, and R4. First up, let’s configure R1’s route to 192.168.4.0/24. Here is the format of the command. From global config mode, IP ROUTE, followed by the destination network IP, netmask, and next-hop IP. So, for R1’s route to the 4.0/24 network The command is this: IP ROUTE 192.168.4.0 255.255.255.0 192.168.13.3. That’s it, fairly simple. I then checked R1’s routing table. Notice I highlighted the code for static routes, it’s S as you might have guessed. And I’ve also highlighted the route itself in the table. Notice in square brackets there are two numbers: one slash zero. What do those numbers mean? They are the route’s “administrative distance” and “metric”. We will cover these concepts later in the course, don’t worry about their meaning for now. I’m just pointing them out in case you’re curious what those numbers are. Okay, that’s all we have to configure on R1. It now knows that, to reach PC4’s network, it should forward packets to 192.168.13.3, R3. Next up, R3. It needs two routes, one to 1.0/24 and one to 4.0/24. The format of the command is the same as on R1. If you can, pause the video and try to figure out the correct commands on R3. Here is the route to the 192.168.1.0/24 network, with R1 as the next hop. And here is the route to 4.0/24, with R4 as the next hop. And then I checked R3’s routing table too. Again, you can see both routes there with their next-hop IP addresses. To reach 192.168.1.0/24, send packets to R1. To reach 4.0/24, send packets to R4. And finally, let’s configure R4’s route to the 192.168.1.0/24 network. Again, try to pause the video and figure out the correct command if you can. Here is the answer. IP ROUTE 192.168.1.0 255.255.255.0 192.168.34.3, using R3’s G0/1 interface IP address as the next hop. And here is R4’s routing table now. So, we have now configured all of the static routes necessary for PC1 and PC4 to communicate. Let’s test it out and see if they can actually communicate with each other. To test it out, I pinged from PC1 to PC4, and the ping was successful. As I’ve highlighted, it says 5 packets transmitted, 5 packets received, 0% packet loss. If the ping is successful, that means there is two-way reachability. PC1 can reach PC4, and PC4 can reach PC1. If PC1 could reach PC4, but PC4 couldn’t send replies back to PC1, the ping wouldn’t work. So, the configurations were successful. Now, let me briefly show how a packet from PC1 to PC4 is encapsulated, de-encapsulated, and re-encapsulated in different frames as it travels through the network. We will examine this process step-by-step in the ‘Life of a Packet’ video coming up soon, so this is just a brief preview. You don’t have to think too much about the process yet. As you saw earlier, when PC1 sends a message to PC4 the Layer 3 destination is PC4’s IP address, 192.168.4.10. However, at Layer 2 the destination is PC1’s default gateway, which is R1’s G0/2 interface. Now R1 has the packet and its R1’s job to forward it to the next-hop, R3. To do so, it encapsulates the packet in a new Ethernet frame. This time the destination of the frame is the next-hop’s MAC address, so the MAC of R3’s G0/0 interface. Now R3 has the packet and must forward it to the next hop, R4. To do that, it once again encapsulates the packet in a new Ethernet frame, and the destination of that frame is the MAC of R4’s G0/1 interface. Now R4 has the packet, and since its directly connected to the destination network, it can forward the packet to PC4. It does that by encapsulating the packet in a frame with PC4’s MAC as the destination. This is the only time in the journey that the destination IP and MAC are of the same device. The destination IP is PC4’s IP, and the destination MAC is PC4’s MAC also. This process is very important to understand, but as I said we will cover it step-by-step in another video. For now, just understand that the source and destination IPs of the packet do not change throughout the journey, but each time the packet is de-encapsulated and re-encapsulated, the source and destination MAC addresses are different. Okay, now I want to introduce another option when configuring static routes. We haven’t configured any routes on R2 yet, so I’ll just use it for this demonstration. When configuring static routes, instead of configuring a next-hop you can configure an ‘exit-interface’ instead. That means you specify which interface this router should send the packets out of, rather than telling it the actual IP address of the next hop. For example if R2 wants to send packets to the 192.168.1.0/24 network, it should send the packets to R1. What interface should R2 send packets out of to reach R1? G0/0, because that interface is connected to R1. So, here’s the command: IP ROUTE 192.168.1.0 255.255.255.0 G0/0. You can type out the whole interface name if you want, or just a shortcut like g0/0 is fine. Now, before we check the routing table there is one more option. You can specify both the exit interface and the next hop. So, if R2 wants to send packets to the 192.168.4.0/24 network, it should send packets to R4. And which interface should it send packets out of to reach R4? G0/1, because its connected to R4. And what is the next-hop IP address? It’s 192.168.24.4, the IP of R4’s G0/0 interface. So here’s the command. IP ROUTE 192.168.4.0 255.255.255.0 G0/1 192.168.24.4. Okay, and here is R2’s routing table now, you can see how each route is displayed. An interesting point is that, when you specify only the exit interface of the static route, it says the destination network ‘is directly connected’. Look at the route I’ve highlighted in blue, 192.168.1.0/24 is directly connected. That network is not directly connected to R2, but that’s how it displays in the routing table when you configure only the exit interface. Static routes in which you specify only the exit-interface rely on a feature called ‘proxy ARP’ to function. This is usually not a problem, but generally you can stick to specifying next-hop only or both exit-interface and next-hop. Neither configuration method is necessarily ‘better’ than the others, just use whichever you prefer. Note that Proxy ARP is beyond the scope of the CCNA, I won’t spend time explaining it here. However, you should know that, when configuring static routes, you can specify the next-hop, the exit-interface, or both. Okay, for the final topic I’ll introduce how to configure a default route on a Cisco router. I introduced the concept of default routes when explaining how a PC’s default gateway works, but let’s review. A default route is a route to 0.0.0.0/0. /0 means that all bits of the netmask are 0, so none of the bits of the address are fixed. They can all change to be either 0 or 1. So, 0.0.0.0/0 is the least specific route possible; it includes every possible destination IP address. If the router doesn’t have any more specific routes that match a packet’s destination IP address, the router will forward the packet using the default route. So, a default route is often used to direct traffic to the Internet. In the network below, R1 is connected to R2 and R3, which are other routers owned by the same business. More specific routes are used for destinations in the internal corporate network, such as destinations connected to R2 and R3. However traffic to destinations outside of the internal network is sent to the Internet, using the default route. This isn’t the only way to use a default route, but it’s a very common use case. Okay, I added some IP addresses to the diagram, and also configured a couple static routes which I’m not showing here. I then checked R1’s routing table. First, notice the part I’ve highlighted. Gateway of last resort is not set. This means that no default route has been configured yet. ‘Gateway of last resort’ is another name for ‘default gateway’. Now, in R1’s routing table there is a route to 10.0.0.0/8 with R2 as the next hop, and a route to 172.16.0.0/16 with R3 as the next hop. Perhaps these are networks used internally by the company. Now let’s tell R1 to send all other traffic to the Internet. Here’s how to configure a default route. The structure of the command is the same as any other static route, but the network and netmask should both be all 0s, 0.0.0.0. And that’s it, R1 now has a default route. I checked R1’s routing table. Let me point out a few things. First, here’s the route. 0.0.0.0 via 203.0.113.2. Notice, next to the S code indicating that it’s a static route, there is an asterisk. What does that mean? In the codes legend it says that the asterisk means ‘candidate default’. It means this route is a candidate to become the router’s default route. It’s possible to have multiple candidates. In this case there’s only this one, and here it states “Gateway of last resort is 203.0.113.2 to network 0.0.0.0”, so the route we configured was indeed selected. Okay, that’s all we’ll cover about default routes for now. The configuration is the same as a regular static route, just remember that the network address and netmask are both 0.0.0.0. We will use default routes in many future lessons as well, so you’ll get more familiar with them throughout the course. Here’s what we covered in this video. We reviewed connected and local routes by looking at the routing tables of R2, R3, and R4. Then we looked static routes and how to enable PC1 and PC4 to communicate over the network. After that we configured the static routes necessary for them to communicate, and here I’ve listed the commands to configure static routes. Usually I just use the first option, specifying only the next-hop IP address, but you should know the other options too. And the final topic was default routes. We looked at default routes earlier in the video when talking about PC1 and PC4’s default gateways, and then at the end we looked at how to configure a default route on a Cisco router. Okay, now let’s go to the quiz to test your understanding of what we covered in this video. Here’s quiz question 1. Which of the following commands configures a default route on a Cisco router? Pause the video now to select the best answer. Okay, the answer is A, IP ROUTE 0.0.0.0 0.0.0.0 10.1.1.255. When configuring a static route on a Cisco router, you cannot specify the prefix length with a slash, you must write out the netmask. So, B and D are incorrect. And in a default route, all bits of the netmask should be 0, as in A, so A is correct. In C the bits are all 1, making it 255.255.255.255. That is not correct. Okay, let’s go to question 2. Examine R1’s routing table. Which interface will it use to forward packets destined for 8.8.8.8? Pause the video now to think about the answer. Okay, the answer is C, gigabitethernet0/2. The only route that matches destination 8.8.8.8 is the default route. This route doesn’t specify an interface, but it does state a next hop of 203.0.113.2. So, if you look at the route for 203.0.113.0/24, you’ll find it’s directly connected to G0/2. So, R1 will send packets destined for 8.8.8.8 to next hop 203.0.113.2, using the G0/2 interface. Okay, let’s go to question 3. Examine the network below. Complete the graph with the static routes needed to allow PC1 and PC4 to communicate with each other. Pause the video now to think about the answers. Okay, let’s check. Note that the graph specifies R1, R2, and R4. We’re not using the path via R3 this time. So, each router in the path needs a route to 192.168.1.0/24 and a route to 4.0/24. R1 has a connected route to 1.0/24, so it just needs this path to 4.0/24, with 192.168.12.2 as a next hop. As for R2, it needs this route to 1.0/24, next hop 12.1, and this route to 4.0/24, next hop 24.4. R4 has a connected route to 4.0/24, so it just needs this route to 1.0/24, next hop 192.168.24.2. Okay, with these routes on R1, R2, and R4, PC1 and PC4 should be able to communicate with each other. Let’s go to question 4. Examine the following static route in R1’s routing table. What command was used to configure this route? Pause the video now to think about the answer. Okay, the answer is D, IP ROUTE 172.20.0.0 255.255.0.0 g0/1. The route states that the network is directly connected, so you might think it’s a connected route added automatically by configuring an IP address, as in option B. However, that is wrong for two reasons. First, the route has the code ‘S’, so it must be a static route. A connected route would have a code of C. And secondly, 172.20.0.0/16 is a network address. You can’t configure a network address on an interface, so the IP ADDRESS command in option B would not work. When you configure a static route and specify only the exit interface, as in option D, it appears as directly connected in the routing table. Then, a technique called Proxy ARP is used to find the next hop. Proxy ARP is beyond the scope of the CCNA, but feel free to google it if you’re curious. Okay, let’s go to question 5. Examine the diagram below. How many static routes would you have to configure on R3 for it to know all destination networks? Pause the video now to think about the answer. Okay, the answer is D, four routes. R3 knows its connected networks, 192.168.13.0/24 and 192.168.34.0/24. For it to know all destination networks in this diagram, you would have to configure four additional routes, to 192.168.1.0/24, 4.0/24, 12.0/24, and 24.0/24. Okay, that’s all for the quiz and this video. I hope it was helpful, thanks for watching.