Difference between revisions of "Routing"
(→Add a new route) |
|||
(One intermediate revision by the same user not shown) | |||
Line 32: | Line 32: | ||
</source> | </source> | ||
− | This tells the router at 192.168.10.1 to send packages destined for the 172.18.0.0 network to the gateway 192.168.20.5 - | + | This tells the router at 192.168.10.1 to send packages destined for the 172.18.0.0 network to the gateway 192.168.20.5 - which we have learned from the above knows how to reach the 172.18.0.0 network. |
+ | |||
+ | ==Learn more== | ||
+ | |||
+ | A good place to learn more about the neworking in general and - in this case - routing is on [http://linux-ip.net/html/tools-ip-route.html this site] or the complete IP manual in [http://linux-ip.net/linux-ip/linux-ip.pdf PDF format] |
Latest revision as of 10:34, 23 August 2018
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 192.168.10.1 dev enp0s25 proto static metric 100 default via 192.168.10.1 dev wlp3s0 proto static metric 600 192.168.10.0/24 dev enp0s25 proto kernel scope link src 192.168.10.183 metric 100 192.168.10.0/24 dev wlp3s0 proto kernel scope link src 192.168.10.184 metric 600 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
The list tells us the if a IP-packet is destined for something else than this computer send it to the 192.168.10.1 computer/router.
On another computer this result will appear:
default via 192.168.20.1 dev enp6s0 proto static metric 100 172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 172.18.0.0/16 dev br-0186fd2cabd8 proto kernel scope link src 172.18.0.1 192.168.20.0/24 dev enp6s0 proto kernel scope link src 192.168.20.5 metric 100
From this we can see that the default gateway to send packages to is 192.168.20.1, but for packages to 172.17.0.0/16 and 172.18.0.0/16 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 172.18.0.3 computer residing in a container on 192.168.20.5 from 192.168.10.183 we need to tell the router at 192.168.10.1 where to send the packages. Perform this command:
]$ ip route add 172.18.0.0/16 via 192.168.20.5
This tells the router at 192.168.10.1 to send packages destined for the 172.18.0.0 network to the gateway 192.168.20.5 - which we have learned from the above knows how to reach the 172.18.0.0 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