Training Cisco 200-125 CCNA v3.0. Day 20. Static Routing

Today we’ll talk about static routing and consider three topics: what is static routing, how is it configured, and what is its alternative. You see the network topology, which includes a computer with the IP address, connected through a switch to a gateway, or router. For this connection, the router port f0 / 0 with the IP address is used.

The second port of this router f0 / 1 with the IP address is connected to port f0 / 0 of another router, and this interface has the address The second router is connected to port f0 / 1 with the address with the third router, which uses port f0 / 0 with the IP address for this connection.

Finally, the third router is connected to the second switch through the f0 / 1 port with the address, and the switch is connected to the second computer with the IP address
If you know how IP subnets can be divided, then determine that the section from the first computer to the first router belongs to one subnet, the section between the first and second routers to the second network, between the second and third routers to the third network and between the third router and the second computer - to the fourth network. Thus, we have 4 different networks.

If the computer wants to contact the computer, then first it must send its data to the gateway It creates a frame in which it places the source and destination IP address, the source and destination MAC address and sends it to the router. He discards the information of the 2nd level, that is, the MAC address, and looks at the information of the 3rd level. Upon learning that the data is addressed to a device with an IP address of, the router understands that such a device is not connected to it, so it just needs to pass this frame through itself further down the network. He turns to his routing table and sees that the data for network 4. needs to be sent to the device with the IP address

Similarly, the second router checks its routing table, finds out that the data for network 4. needs to be sent to the IP address, and sends the frame to the third router. Finally, the third router checks its table, determines that network 4. is connected to it itself, and sends the frame to the second computer.

Let's look at how a routing table is created. To do this, we use the Cisco Packet Tracer and see how the concept of routing is implemented. The same network topology is shown here, and now I will assign the appropriate IP addresses to the routers, also indicating the default gateway addresses.

We do nothing with the switch, because it works with the default settings and uses VLAN1. Let's proceed to the settings of the first router Router0. First, assign it the host name R1, after which we write down the IP address and subnet mask for the f0 / 0 interface. Then you need to use the no shutdown command. You see how the interface marker has changed from red to green, that is, the port is connected to the network.

Next, we need to configure the second port of the router f0 / 1, while the host name remains the same, we just add the IP address and the subnet mask There is nothing new here, this is a simple setup, you already know all the commands, so I will quickly go through the rest of the routers. As I assign IP addresses and use the no shut command, the ports of the routers will turn green to indicate that the connection between the devices is established. At the same time, I create networks 1., 2., 3. and 4. The last octet of the IP address of the router port indicates the number of the router itself, and the penultimate octet indicates the number of the network connected to this port.

Thus, the first router will have the port addresses (the first router, the first network) and (the first router, the second network), the second router - (the second router, the second network) and ( the second router, the third network) and the third router has (the third router, the third network) and (the third router, the fourth network). In my opinion, this is pretty easy to remember, but in reality, addresses can be formed differently, depending on the rules adopted by your company. You must adhere to the rules of the company, because it will be easier for your colleague to troubleshoot your network if you configure it in accordance with the rules.

So, I finished assigning IP addresses to the ports of the router, and you see that the port of the second switch also changed color to green, since the connection between it and the second computer was created automatically.

Now I will call the command line terminal of the first computer and ping the second computer at Let's move on to the simulation mode - now you see the animated movement of the ping packets across the network sections. Now I will start pinging again so that you can carefully see what happens. On the right in the table you see ICMP, Internet Control Message Protocol - that is how ping is indicated. Ping is a protocol that we use to test the connection.

You send a test packet to another device, and if it returns it, then the connection is successfully established. If you click on the ping packet in the diagram, you can see the transfer information.

You see the OSI level 3 data - these are the IP addresses of the ping source and destination, the 2nd level data in the form of the corresponding MAC addresses and the 1st level data in the form of the port (s) - this is FastEthernet0. You can also look at the format of the ping frame: the header, type, and body of the package.

The frame goes to the switch, the switch analyzes the MAC addresses and sends it further through the network to the router. The router sees the IP address and discards the packet because it does not know such an address. Let's see what happens in real time, for which we return to the ping in the command window.

You see that when trying to ping the computer all 4 packets were lost - from the router a response was received that the destination host is not available. Go back to the router command line interface window and enter the show ip route command. You see the most important part - the routing table, and the command I entered is one of the main Cisco routing commands. This table currently contains 2 entries. At the beginning of the table is a list of abbreviations used, which shows that the letter C denotes compounds. The first entry reports that the network is directly connected to the FastEthernet0 / 0 port, and the network is directly connected to the FastEthernet0 / 1 port. This means that at the moment the router knows only these two networks.

The value is the network identifier. When we created the subnets, we simultaneously created their identifiers. These identifiers tell the router that all devices whose IP addresses range from to are located on this subnet. Thus, all these devices should technically be available for the router, since it is connected to this network.

If the value of / 24 is located at the end of the identifier, this means that a broadcast request will be sent to all devices on this network from the 1st to the 254th. So, only networks 1. and 2. are connected to this router, so he knows only about these networks. Therefore, when the ping with the address gets to the router, it does not know that this address is available on the route Router0-Router1-Router2.

But you, as the network administrator, know that this route is available, that is, that the first router can send this packet to the second router. Therefore, you should organize static routing. Let's try to do it.

We will tell this router that any packet and any traffic destined for the network should be sent to the second router. The command format for assigning static routing is as follows: ip route <network identifier> <IP address of the subnet mask> <IP address of the gateway>.

Now I will show you what this means. We use the global configuration mode of the router settings for this command. I type ip route - this means that any traffic for network devices that have an IP address of the last octet value from 1 to 254 gets here, and then I type either the IP address or the port designation where send this traffic. In this case, I type in the designation of the interface f0 / 1, that is, the command takes the following form: ip route f0 / 1.

Instead of the gateway interface, I can specify its IP address, then the static routing command will look like ip route

You may ask which is better. I think that for broadcast networks such as Ethernet, it is better to specify an IP address. If you use point-to-point networks, such as Frame Relay (relay networks, or frame switching), it is better to use the exit interface. Later we will look at Frame Relay networks, but now I use a more suitable version of the routing command -

Let's now look at the routing table using the do show ip address command. You see that a new entry appeared in it, entitled S, that is, static.

This entry indicates that if there is traffic for the network, it must be forwarded to the addressee through the device with the IP address We return to the command line of the computer and ping the desired address again. Now traffic should go through the first router and reach the second router, which should drop packets.

In the first case, the router did not just drop the packets, it also answered the computer that the IP address was not available. However, the second router can only respond to the first router from which it received traffic. Let's look at the routing table of the second router. It says here that Router1 only knows networks 2. and 3. and knows nothing about network 4. where it should send packets to the first computer. He would send back a message that the destination host is not available, but does not know how to contact the computer that sent these packets, because he does not know anything about network 1. That's why instead of the message about the unavailability of the destination host, we received the message Request timed out - Request timed out. Different network devices have different TTL values, so when IP packets reach this value, they are destroyed. In this case, a countdown occurs - one hop is performed, and the TTL counter changes from 16 to 15, the second from 15 to 14, and so on, until the TTL value reaches 0 and the packet is destroyed.

This is how the IP packet loopback prevention mechanism works. Thus, if the device does not receive the request at the set time, the system displays a similar message. Therefore, let's move on to the settings of the second router and show him how to reach the fourth subnet. For this I use the ip route command. Now the corresponding entry appeared in the routing table, which we called with the do show ip route command.

Now Router1 knows how to send traffic to the fourth subnet destination. He sends it to the third router. The third router, Router2, since network 4 is connected to it, definitely knows how to send a packet to a second computer.

What happens if I send ping again? After all, now all network devices know how to reach a second computer. Will ping the IP address now succeed? No, it will not!

As I said before, ICMP is a two-way communication protocol, so if someone sends ping packets, they should go back. Routing consists in the fact that each network device must not only know how to send a message to someone, it must also know how to deliver a response message to the sender of the request. So, the packet sent by the first computer successfully reached the second computer. The second computer thinks: "excellent, I received your message and now I must send you an answer." This response, addressed to the device with the IP address, gets to the router Router2. The third router sees that it should send a packet to the first subnet, but in its routing table there are entries only about the third and fourth subnet. Therefore, we must create a static route using the ip route command. This command says that traffic destined for the network with the identifier should be sent to the second router with the IP address

What will happen after that? The second router knows about networks 2., 3. and 4., but knows nothing about the first network. Therefore, you need to go into the settings of the second router Router1 and use the ip route command, that is, indicate that traffic for network 1. should be sent over network 2. to the first router Router0.

After that, the packet reaches the first router that knows about the device, because the first network where this computer is located is connected to the port of this router. I note that now the first router does not know anything about network 3., and the third router does not know anything about the second network. This can create a problem because these routers are not aware of the existence of intermediate subnets.

I ping the address again, and you see that this time the ping was successful. Packets went all the way from the first to the second computer and the response was returned to the sender. A message appears in the command window that each of the 4 response packets represents 32 bytes, TTL = 125 ms, and the ping success is 100%. This means that the transmission source received a response from the destination host. Thus, even if the devices are not aware of the existence of some intermediate networks, it does not matter if they work on the principle of “final sender - final recipient”. The first computer knows how to get to the second computer, and the second - how to get to the first.

Let's look at a different situation. So, the first computer can successfully communicate with the second computer, while traffic passes through all these devices. Let's see if PC0 can communicate with the third router Router2 at the address - this is the network port 3 of the third router. Ping shows that this is not possible - the destination host is unavailable.

Let's see what is the reason. Having opened the routing table of the first router, we see that he knows only 3 networks - the first, second and fourth, but does not know anything about the third network. Therefore, if I want to contact this network, I need to set a static route for it.

So, we looked at how you can configure static routing for three routers. If you have 10 routers and 50 different subnets, manually configuring static routing will take a lot of time. That's why we need dynamic routing.
Now I will delete all the routes that I created. To do this, I will call the routing table of all routers one by one and add the word “no” at the beginning of each static routing record, that is, I use the negation command. Now we can consider what dynamic routing is.

For dynamic routing, I have to activate the RIP protocol, it is a very fast protocol. But today we will not discuss RIP, our topic is static routing, and I wanted to show you how painstaking and tedious this is. Nevertheless, I will quickly demonstrate to you how RIP works, which we will examine in detail in the next lesson.
In the example of the first router, I use the router rip command, then I enter ver 2 to indicate the version of the protocol, and then list the networks for which you want to use the dynamic routing protocol:,, then go to the second router and I will do the same with him. Technically, I just indicate the networks that are connected to this device, so for the second router I will specify and, and for the third after the rip ver 2 command, the addresses and Then I will return to the first router and look at the routing table.

You see that all networks magically appeared in it, the first two are those that are connected directly to the router, and the other two are those that are connected via the dynamic routing protocol RIP. A similar situation is observed in the routing tables of the second and third routers. If I connect networks 5. and 6. to the second router, then all devices using RIP will be aware of these new networks. This is the advantage of dynamic routing.

If I now ping a second computer, the connection will work without problems. I can ping the third router, and ping will be successful, because the first router thanks to RIP knows about all the devices of all networks. The second and third routers will have a similar “knowledge”. I'm not saying that RIP is the best protocol, but it can do a lot of things efficiently. For now, I just want you to understand what routing is and how it works, what a routing table is and what its meaning is.

Regardless of whether you use static or dynamic routing, the role of protocols is to populate the routing table. This table should be aware of all routes to all devices on the network so that one device can establish a connection with another device.

So, today you learned that routing is a process that ensures that entries about routes appear in routing tables so that the router can decide to send traffic over the network.

Thank you for staying with us. Do you like our articles? Want to see more interesting materials? Support us by placing an order or recommending it to your friends, a 30% discount for Habr users on a unique analogue of entry-level servers that we invented for you: The whole truth about VPS (KVM) E5-2650 v4 (6 Cores) 10GB DDR4 240GB SSD 1Gbps from $ 20 or how to divide the server? (options are available with RAID1 and RAID10, up to 24 cores and up to 40GB DDR4).

Dell R730xd 2 times cheaper? Only we have 2 x Intel TetraDeca-Core Xeon 2x E5-2697v3 2.6GHz 14C 64GB DDR4 4x960GB SSD 1Gbps 100 TV from $ 199 in the Netherlands! Dell R420 - 2x E5-2430 2.2Ghz 6C 128GB DDR3 2x960GB SSD 1Gbps 100TB - from $ 99! Read about How to Build Infrastructure Bldg. class c using Dell R730xd E5-2650 v4 servers costing 9,000 euros for a penny?


All Articles