DEV Community

Cover image for An Extraordinary Network Setup Where You Can ping to Google but not to Facebook From the Same System
Piyush Bagani
Piyush Bagani

Posted on

An Extraordinary Network Setup Where You Can ping to Google but not to Facebook From the Same System

Hello Readers😊,

In this article, I am going to show you all an extraordinary setup of networks where You can ping to Google but not to Facebook.

Isn’t it Fascinating…

This setup requires some basic foundations in Networks but don’t worry I’ll try to explain all the steps from scratch and after reading this article you will able to do this setup very easily. So without any Further Delay Let’s Get Started✔✔.

Whenever we ping to any IP address, our network program internally first checks the routing tables to confirm that does the IP we are pinging to typically called destination IP lies in network range or not. NetMask is responsible for deciding the range. If the destination IP doesn’t belong to the same Network Range, then our system will not generate packets. As it will not create any packet. It will not ping.

So Let’s Start with the setup. Here we will use RedHat Enterprise Linux-8 as our Base OS.

As discussed, We have something called routing tables. For a network, to know where to send packets of data it receives, it uses a routing table. The routing table contains a list of specific routing destinations. When the router receives a packet of data, it references the routing table to know where to send that data. The routing table may also contain information on how far each destination is from the router. In essence, a routing table is a map for the router.

The Routing Table of our System is shown below:
alt text
From The Above image, We can see that in our routing table, we have 2 rules. The first is that belongs to our netmask 192.168.0.0 and the Second one 0.0.0.0 is the default gateway with 0.0.0.0 as netmask, used to connect to all IP(s) available.

By using this default rule 0.0.0.0 we are able to ping Google, Facebook, or any other IP.
alt text

Now for this interesting setup, we have to delete this by default rule 0.0.0.0 using the command — route del -net 0.0.0.0. After running this command in the terminal we can see in the routing table, we don’t have that rule.

alt text

Also, Notice That Now we are not able to ping Google and Facebook. This is because we deleted the by default rule using which were able to ping to both of them. Hence the packets aren’t created and it shows Network is unreachable.

Now we have to add the new rule in the routing table so that we can ping to Google. For that, we must now the IP address of Google. nslookup is a command in RHEL8 which helps us to do that.

alt text

So, There it is. The IP address is 172.217.167.164. We have to add a rule in routing table. Command to add rule can be seen in image below:

alt text
Here we add “/30” which is netmask or typically known as prefix length. Further “gw” option is used to specify the gateway and at last we have to specify, the network card name in our case it is enp0s3.

After running the above command the route table looks like:
alt text
Thus now if we try to ping Google, It will be successful and We will clearly see the transmission of packets.
alt text
Now Let’s Try to ping Facebook.
alt text
See it shows the network is unreachable, It means even the packets are not created.

Voila, We did It.

Let’s Try to do same task from Firefox browser.
alt text
Here We go, we are able to connect to Google. Lets Give a Try on Facebook.
alt text
It shows Unable to connect. This is because we have specified the rule in the Routing table which only belongs to the Google.

So our the Setup of Extraordinary Network is Successful. I hope You get something new out of This setup.

That’s All. Thank You So Much For Reading😊

Keep Learning, Keep Hustling.

Top comments (0)