Routing in Linux

From docwiki
Revision as of 16:21, 27 March 2020 by Mond (talk | contribs) (How packets find their way)
Jump to: navigation, search


Motivation

We have already seen that IP packages do not only exist on your local network but are routed between networks around the world. How does routing in Linux work? Who do the package know which way to travel? What if you want to build your own router using a Linux system? Here you will learn the basics of how to do this.

How packets find their way

Let's assume you share your house with another family. You life on the first floor and the other family lives on the 2nd floor. You only have one Internet connection abut you want to share it with the other family. Yet you do not completely trust them so you want them on their own network segment.

In between the networks you an old PC that should work as a router. This could be the setup displayed below:

For the 1st floor you use: 192.168.1.0/24 and for the 2nd floor you use 192.168.2.0/24 addresses. The vertical bars symbolize the network. In the drawing we have only drawn one computer in the first network and one in the 2nd and one computer that has legs in both networks that should work as a router.

So when a computer on the 2nd floor, e.g. 192.168.2.37 whats to send packets to the 192.168.1.0/24 network, how do the packets know where to find that network? What is needed is a route, which is kind of a sign post for packets to tell them which way to go. The sign post in the example below would have to look like the one painted there. All packets with a destination in the 192.168.1.0/24 network, please go to the station 192.168.2.7, this station gives you further direction.

Route.png