From Klaus' wiki
Jump to: navigation, search

Basically routing is about telling your network part of the kernel where to send a packet to.

If you perform this command:

]$ ip route

you'll get the settings for your local computer.

From my home laptop it looks like this:

default via dev enp0s25 proto static metric 100 
default via dev wlp3s0 proto static metric 600 dev enp0s25 proto kernel scope link src metric 100 dev wlp3s0 proto kernel scope link src metric 600 dev virbr0 proto kernel scope link src linkdown 

The list tells us the if a IP-packet is destined for something else than this computer send it to the computer/router.

On another computer this result will appear:

default via dev enp6s0 proto static metric 100 dev docker0 proto kernel scope link src dev br-0186fd2cabd8 proto kernel scope link src dev enp6s0 proto kernel scope link src metric 100

From this we can see that the default gateway to send packages to is, but for packages to and should go through the bridges created by the docker container handler.

Add a new route

Some times we need to tell a computer to make a new route. For instance if we would like to reach the computer residing in a container on from we need to tell the router at where to send the packages. Perform this command:

]$ ip route add via

This tells the router at to send packages destined for the network to the gateway - which we have learned from the above knows how to reach the network.

Learn more

A good place to learn more about the neworking in general and - in this case - routing is on this site or the complete IP manual in PDF format