Playing with Ip’s and Netmask!!!

Task#13: Create a setup where you can ping Google but not able to ping Facebook with the same system?

--

To create such a setup we must have some basic knowledge of networking, IPs, working of switches and routers, route tables, netmask, or network name.

I have performed this task in RHEL8 (RedHat Enterprise Linux 8) OS, running over virtualization.

Step#1: First, we have to check the IP of the OS we are using,

IMG 1: The IP address of the RedHat system

the command to check the IP in Linux is “ifconfig enp0s3”, where enp0s3 is my network card name. Now we know that our IP address is 192.168.43.55 with netmask/network name as 255.255.255.0.

Step#2: Second, we will check the routes in our route table so that we can change them to create our setup.

IMG 2: Route Table

We use the “route -n” command to see the routing table. It shows us the starting IP which is the destination IP, Gateway which will take our requests to the outer world, Genmask which is our netmask, and much more information.

Step#3: We will now find the IP addresses of both Google and Facebook to use in the next steps.

IMG 3: The IP of Google is 142.250.183.110.
IMG 4: The IP of Facebook is 69.171.250.35

nslookup <domain_name>” is the command we will use to find the IP addresses of both.

Google: → 142.250.183.110

Facebook: → 69.171.250.35

Step#4: After gathering all the necessary information we will start our setup. Now, we will delete the first route from the routing table as it is the universal route that can ping and create packets for all the systems that are connected to the internet. If we will not delete this entry then we will not be able to stop our system from pinging Facebook.

IMG 5: Route table after removing the Universal route.

“route del -net 0.0.0.0” is the command used to delete the universal route from the routing table. In the second part, the above image shows the routing table without the Universal route.

Step#5: This is the most important step of this setup. Here we will add a route in the routing table which will satisfy our requirement of pinging Google and not pinging Facebook.

IMG 6: Adding route in the routing table

“route add -net 142.250.183.108 netmask 255.255.255.252 gw 192.168.43.144 enp0s3” is the command to add a route in the routing table. Here -net is used for setting up the first IP of the network name, netmask is used to define the range of IPs the network will contain, gw is the gateway which will help us to go to google using the public IP (we can find the gw IP from IMG 2 before deleting the Universal route), and enp0s3 is our network card name.

The above route will contain only 4 IPs because we have performed subnetting by creating a sub-network from a super-network.

In the second part of the image, we see the updated routing table with the entry we added.

Our setup is completed, now we have to check whether it is working or not.

We will ping both the IPs of Google and Facebook from our OS. What we expect is, our system will be able to ping Google but not Facebook. As we can also access any website using their IP address so we will use an IP address instead of their domain name (you can use any).

While pinging, if the IP we are pinging to is in the range of any entry in the routing table then the system will create packets and send them to that IP. If that system is live it will reply by sending back the packets or it will not reply. If the IP is not in the range of any entry in the routing table then the output will be Network is unreachable.

Pinging Google using its IP.

“ping 142.250.183.110” will ping to google and google will respond back because of the setup and changes we made to our routes.

Pinging Facebook using its IP.

“ping 69.168.43.144” will not be able to ping as we have not added any route that will allow our system to use the gateway to go to the IP of Facebook.

Alas! Hence, our setup is complete.

Learned from ARTH: The School of Technologies

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response