Networking is the exchange of information and ideas among people with a common profession or special interest, usually in an informal social setting. Networking often begins with a single point of common ground.
In my previous article, I have talked about networking and many other concepts related to it and which is required to understand today's practical so if you are new to networking you can go through my article using this link for better understanding of this demo.
In this article I would be creating a custom network by which we can able to ping system A from B & C and vice versa but system B and C cannot able to ping each other despite having a connection, So to achieve this network topology we will be using route tables.
Today we will burst a myth that if system A can ping to B & C and vice versa, then B and C can also ping each other. We can also use the firewall to accomplish this task very easily but to better understand the internal concept we use routing table.
So let's start with the implementation
I have 3 system of RHEL8 first, we will check the IP of the system using ifconfig command.
So now if we will try to ping from System A to B & C it is possible and as of now pinging between B & C is also possible.
Changing the IP address of the system
we can perform this operation from the existing IP address but from the simplicity, we will provide our own custom IP address.
So for this, I will create a network of 16 IP which will get distributed in these systems.
Like system A will get 126.96.36.199 with a netmask of 255.255.255.240
system B → 188.8.131.52 and netmask /28
system C → 184.108.40.206 and netmask /28
Here this netmask tell the network name like in my case my network name is 220.127.116.11/28
255.255.255.240 is same as /28 as it is the “32–24” the power of 2 which is equal to 16 means there are 16 IP in the network and 256–240=16 which also give the same no of IP that can exist in the network.
So for changing the IP we will use the command
ifconfig <network_card> <IP>/<netmask>
From the above, you can clearly observe that the IP address of the system is changed now with our custom IP address.
Now we don't have to take care of the rule in the routeing table which was preexisted as now we don't have that network so it's of no use.
Adding new rule in the routeing table
The construction of routing tables is the primary goal of routing protocols. Static routes are entries made in a routing table by non-automatic means and which are fixed rather than being the result of routing protocols and associated network topology discovery procedures.
we can also delete previous route table using the command
route del -net <dest_IP>/<netmask>
Now let's add the rules to our route table according to our experiment
System A (IP 18.104.22.168) → 22.214.171.124/28 (28 consists 16 ip’s starting from 0 to 15)
System B (IP 126.96.36.199)→ 188.8.131.52/29 (29 consists of 8 IP's starting from 0 to 7)
System C (IP 184.108.40.206)→ 220.127.116.11/30 (30 consists of 4 IP's starting from 4 to 7)
You can all clearly see that System A IP range is common in both B & C but B & C don't share command IP range for their own IPs so they are not allowed to create particle from each other and these are not IPs now these are IP range for the routeing table if the destination IP belongs to this range then the only system can create packets.
Let's write these rule in route table using the command
route add -net <destination_ip>/<netmask> <network_card>
Now lets test if our created topology is working as per requirement or not
Firstly I am going to ping B & C from system A
So we can see that system A can ping to B & C but B and C are not allowed to ping each other, by this our created topology is working fine this the power of route table they are not allowed to connect despite having a connecting.
If you want to reset these setting of route table you can just add a rule or simply switch off device network connecting and then turn it on as router have DHCP server which will automatically build route table for us and now you are back to normal.
So Only by using routing tables, we can design a great network topology where some systems connect to any system in the same network and some systems only can connect to specified systems even though they are in the same network.
Hopefully, you learn something new from the article as well as enjoy it.
Thanks for reading this article! Leave a comment below if you have any questions.