Kubernetes - Networking
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
: Networking : From Linux perspective
: Networking : Switching
How does system A reach B , we connect them to a switch and the switch creates a network containing the two systems . To connect them to a switch we need an interface on both the nodes. Physical or virtual depends on the host.
To see the interfaces for the host we use the IP link command .
In this case we will see the interface called eth0 that we will be using to connect to the switch.
In this case we see an interface named eth0 , that we will be using to connect to the switch .
Lets assume is a network with 192.168.1.0
We then assign the ip addresses to the systems on the same network.
For this we use the command ip addr , once the link is up and IP Addresses are assigned. The computers can now communicate to one another through the switch .
A switch can only enable communicate within a network which mean it can receive packets from one network and deliver it to another networks . Say we have another network containing C and D .
How does one system in one network reach the system in another .
A router helps connect two networks together.
Thats when a router comes in . A router helps connect two networks together it is an intelligent device so think of it as an another device with many network ports. since it connects to two networks it gets 2 IPs assigned.
One on each network , in the first network we assign an IP 192.168.1.1 and 192.168.2.1 .
Now we have a network connected between them
That's where we configure the system via a Gateway, via a route - If the network was a room , gateway is a door to the outside world to the other network or to the internet - the systems need to know where the door is to go through that . To see the existing routing configuration on the system run the route command.
As you can see there is no routing configuration above , in this condition your system B cannot reach System C . It can only reach other systems within the same network.
to configure a gateway on system B to reach the system on 2.0
on the IP route add command
$ ip route add 192.168.2.0 via 192.168.1.1
running the route command again.
if system c has to sent a packet to system b
ip route add 192.168.1.0/24 via 192.16.2.1 // this has to added to system C's routing table
to access the network of 1.0
Supposing you need access to the internet
ip route add 172.217.194.0/24 via 192.168.2.1
there are so many different sites on networks on internet . Instead of adding the same routers ip address to each of those networks.
To any network that you dont know to route to . Use this router as the default gateway .
ip route add default via 192.168.2.1
Instead of the word "default" you can also say "0.0.0.0"
the "0.0.0.0" entry in the gateway field indicate that you do not need a gateway
an example of a route table is as below.
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default gateway 0.0.0.0 UG 100 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
Supposing assume you have multiple routes one for the internet and one for the internal private network . Then you will have two separate entries for each network.
ip route add 192.168.1.0/24 via 192.16.2.1
ip route add default via 192.168.2.1 -- one default gateway for internet
How to set up Linux host as a router
There are three servers A, B and C . B server is connected to both the networks
How can A speak to C.
If we try to ping server A to C , you will get a message network not available.
Comments
Post a Comment