Creating a Custom Network Topology Using the Routing Table

Yash Agarwal
Jan 14 · 5 min read
Image for post
Image for post

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

Image for post
Image for post
System A
Image for post
Image for post
System B
Image for post
Image for post
System C

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

So for this, I will create a network of 16 IP which will get distributed in these systems.

Like system A will get 1.2.3.6 with a netmask of 255.255.255.240

system B → 1.2.3.1 and netmask /28

system C → 1.2.3.11 and netmask /28

Here this netmask tell the network name like in my case my network name is 1.2.3.0/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>

Image for post
Image for post
System A
Image for post
Image for post
System B
Image for post
Image for post
System C

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

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 1.2.3.6) → 1.2.3.0/28 (28 consists 16 ip’s starting from 0 to 15)

System B (IP 1.2.3.1)→ 1.2.3.0/29 (29 consists of 8 IP's starting from 0 to 7)

System C (IP 1.2.3.11)→ 1.2.3.4/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>

Image for post
Image for post
System A
Image for post
Image for post
System B
Image for post
Image for post
SYstem C

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

Image for post
Image for post
ping from System A to System B
Image for post
Image for post
ping from System A to System C
Image for post
Image for post
ping from System B to System C

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.

Conclusion

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.

The Startup

Medium's largest active publication, followed by +773K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store