Whenever we are talking about networking or pinging to different networks we are unable to understand how the things are actually working in the background.
So today I would be breaking down the concept behind the networking and I would be creating a network from which we can ping to google but not to facebook. This might not sound like a great idea but the concept covered would be of paramount importance.
Before beginning I would like to define a few terms that are very important in networking and might help you to understand the concepts behind it more nicely.
- Switch: Switch is a component that allows a system to connect to a different computer in the same network.
- Router: Router is a component in the computer or a seperate device that allows a system to connect to a different system of a different network.
- Routing table: Routing table is like a data table maintained by a computer that lays down the rules about connecting to different systems or networks.
- Packet: Whenever we are pinging to different machines our system creates a packet. If the connection is not allowed by the rules of the routing table then this packet is not created.
- Gateway: The gateway is the place in the network from which the computer connects to the internet or some other network. Without knowing the gateway it is not possible for the system to connect to the internet.
- Network Card: A network card is a hardware component of the computer that connects a computer to a computer network
I would be using the RHEL8 OS today so the commands are explicit it but the same concept can be replicated on any operating system using the OS specific commands .
To view the routing table we use
There is a lot of information so let’s break it down. The main components are the destination IP, Gateway and Genmask also known as netmask.
The destination IP tells about the range of IP that the route table allows to connect to. The gateway performs the same task as I mentioned earlier.
The Genmask or the netmask helps in getting the name of the network from the destination IP. Netmask is a concept of interest on it’s own so I won’t dwell on it deeper since there is not much need for it today.
The Use Iface tells the name of the network card. In our case we are using the enp0s3 network card.
Let’s start our research
So let’s see right now how the network is performing
The IP 188.8.131.52 is the IP of google and it is working fine. So let’s see if we can ping facebook server or not.
The IP 184.108.40.206 is the IP of the facebook server and the connection is working just like it is supposed to.
To show the importance of the route table in making this connection let’s just drop the rule allowing this from the route table.
So the rule I dropped had the information about the gateway and the destination IP. That rule was allowing my system to connect to the internet i.e google server ,the facebook server or any other IP on the internet that is working.
But you don’t need to take my word for it. Let’s try pinging to the google and the facebook server again.
Now we can see that the server is unreachable although I have complete internet connectivity as before.
So where did the problem arise
As I mentioned earlier there is no issue with the internet connectivity. When we ping, the system goes to the route table and since there is no rule to connect to the given IP it simply denies the permission to even try to connect. This means the network packet is not even created in such a scenario.
So since I established the fact that without a properly configured route table we cannot access the internet , let us understand the importance of the gateway.
Now I would be adding a new rule to the route table.
So now I specifically added the google server IP to my route table. However you can notice the gateway is not yet updated.
Let’s try pinging to google again.
Oh another error. But this time it doesn’t say “Network is Unreachable”. This means the packet is being created.
What does this signify?
This proves the point that since the rule is added in the route table regarding the destination IP of the google server the packet is created. The error we got here was because of the incorrect gateway configuration.
So let’s clear it up too.
So the new rule is just like the rule I added before it and the only difference is the fact that the gateway is configured now.
So let’s try pinging again.
Nice!!! So it’s working great like before . So since the internet connectivity is great and I am able to reach to the google . Let’s try pinging to the facebook server again.
What? Well this was expected since the facebook server is not allowed in the route table since we explicitly allowed only the destination IP of google .
So we configured a custom route table that allows only certain IP’s connection to be made.
So we broke a very prominent myth here that having the internet access allows us to connect to any website on the internet. This is not completely the case. Since today we had the internet connectivity at all times yet we were unable to ping to the server until we configured the route table.
Networking is one of the most interesting topic in technology there is so much going on when we just power on our system or click a link that opens another webpage.