Creating a network setup that can ping Google but unable to ping facebook from the same system

ADARSH KUMAR
3 min readDec 14, 2020

We will follow step by step to create this setup.

Step 1:

First we check the connectivity with the both google.com and and facebook.com.

Here we can see that we are able to ping both google.com and facebook.com. But we want a setup that can ping to google but not facebook.

Step 2:

We have to understand how our local system can ping to online servers .

When we ping to any server, Our system send packets to that server, but to send the packets our system must have rule for that server ip range , If the rule is not available in the routing table then, our system can’t ping to that server.

Since, we are able to ping both google and facebook, so we have to check the routing table.

Here we can see that there is destination=0.0.0.0 and Gateway=192.168.43.1 ,by this rule our system is sending packets to the servers of google and facebook,So If we delete this rule ,then our system can’t ping to google or facebook or any other online servers.

step 3:

Before deleting the rule from the routing table ,first get the ip of google and facebook for further use.

[root@localhost ~]# nslookup facebook.com & nslookup google.comServer:     192.168.43.229
Address: 172.31.2.2#53
Non-authoritative answer:
Name: facebook.com
Address: 69.171.250.23
Name: facebook.com
Address: 2a03:2880:f1ff:83:face:b00c:0:25de
Non-authoritative answer:
Name: google.com
Address: 216.58.193.174
Name: google.com
Address: 2404:6800:4007:813::2004

So we got the ip of facebook.com and google.com ,Now delete the rule.

[root@localhost ~]# route del -net 0.0.0.0

Now, We will try to ping google and facebook, and lets see what are we getting.

So, now our system is unable to ping to both google.com and facebook.com or any other online servers,because we dont have any rule for it in our routing table.

Step 4:

Since we don’t have any rule to ping outside world ,but our requirement is to ping google.com.

So we will create a rule in the routing table for the google, so that our system can ping to google.com

[root@localhost ~]# route add -net 216.58.192.0 gw 192.168.43.1 netmask 255.255.224.0 enp0s3

the ip we got from the ‘nslookup’ command of the google(216.58.193.174) is a part of range of google ip(216.58.192.0 — 216.58.223.255), so the netmask for this ip range will be 255.255.224.0, so our destination will be 216.58.192.0 and our gateway will be 192.168.43.1.

Step 5:

Now let’s check whether we are able to ping google.com or not and what about facebook.com.

Here , we can see that after adding the rule we are able to ping google.com. But we are unable to ping facebook.com,because we don’t have any rule for its ip range.

Conclusion

We have successfully created the setup that can ping google but unable to ping facebook.

Thank you!!

--

--