DEV Community

Cover image for Network Topology Setup in such a way that System A can ping to two Systems B & C but both systems not able to ping each other
Sri Vishnuvardhan A
Sri Vishnuvardhan A

Posted on

Network Topology Setup in such a way that System A can ping to two Systems B & C but both systems not able to ping each other

Note: We are not going to use any firewall, since it is simple and everyone aware of this, so we are going to use unique way to achieve this topology setup.

Concepts used: Routing tables and Netmask

In this practical, We are going to use three Redhat Enterprise Linux Virtual Machines which are hosting by Oracle VirtualBox.

I already explained these Routing table and Netmask concepts in my previous blog, if you want to know these basic concepts then please refer this

Note: Before starting these VM's, make sure that it is connected in Host-only adapter mode and the adapter name should be the same in all three VMs.

image

Environment Setup

System A

First step is to change the IP and set the Netmask by running the following command.

ifconfig enp0s3 162.168.1.1/29

image
Second step is to create the route rule by running the following command.

route add -net 162.168.1.0 netmask 255.255.255.248 enp0s3

image

System B

First step is to change the IP and set the Netmask by running the following command.

ifconfig enp0s3 162.168.1.2/31

image
Second step is to create the route rule by running the following command.

route add -net 162.168.1.0 netmask 255.255.255.254 enp0s3

image

System C

First step is to change the IP and set the Netmask by running the following command.

ifconfig enp0s3 162.168.1.4/31

image
Second step is to create the route rule by running the following command.

route add -net 162.168.1.0 netmask 255.255.255.254 enp0s3

image

Ping Checking

Now, We completed the environment setup. Now we have to run the ping command in order to check the status of Network connectivity.

Pinging System B from System A

image

Pinging System A from System B

image

Pinging System C from System A

image

Pinging System A from System C

image

Pinging System B from System C

image

Pinging System C from System B

image

How is this Possible?

In simple words, it happened because of routing tables that use the Netmask for the IP range.

Let's take a look at the routing rule in System A

route add -net 162.168.1.0 netmask 255.255.255.248 enp0s3

In this, Netmask 255.255.255.248 denotes the IP range which have the connection between them.
If you convert to binary form means, it looks like this.

11111111 11111111 11111111 11111000

For the last three places(where the zeros located), we can accommodate 8 combinations. So it decided the number of IP's (IP range) that can connect each other.

The range of IPs are that can connect each other is 162.168.1.0–162.168.1.7.

So in this way, System A can ping to System B (162.168.1.2) and System C (162.168.1.4).

Then if you look at the routing rule in System B.

route add -net 162.168.1.0 netmask 255.255.255.254 enp0s3

The netmask is specified as 255.255.255.254
If you convert to binary form means, it looks like this.

11111111 11111111 11111111 11111110

For the last one place(where the zero located), We can accommodate 2 combinations. So it decided the number of IPs (IP range) that can connect each other.

So the range of IP's that are connected to each other are two in numbers namely 168.162.1.0 and 162.168.1.1.

In this way System B can ping to System A. It is noted that IP of System C (162.168.1.4) is not in range, that's the reason for not ping.

Finally, if you take a look on routing rule in System C.

route add -net 162.168.1.0 netmask 255.255.255.254 enp0s3

Here, the Netmask specified is 255.255.255.254. So the last one place(where the zero located), we can accommodate 2 combinations. So it decided the number of IPs (IP range) that can connect each other.

So the range of IPs that are connected to each other are two in numbers namely 168.162.1.0 and 162.168.1.1.

In this way, System C can ping to System A. It is noted that IP of B(162.168.1.2) is not in range, that’s the reason for not ping.

Thats it. Hope this practical help you to undertand the concepts of Netmask and Routing tables and its use cases in Networking. Stay tuned for my next article!!

Top comments (0)