A Setup To Only Ping Google but not Facebook

Dhruv Upadhyay
3 min readMar 14, 2021

--

So today we will try to change some network configuration using basic networking commands such that my local RHEL8 system can ping to Google but not Facebook

Step-1

So, before directly jumping on to the practical, do check your internet connectivity and also check whether both sites are pingable or not. By using the following commands -

ping google.com

ping facebook.com

Step-2

So to create a setup we need the IP address of Google and Facebook. One must also remember that both Google and Facebook have multiple IPs, so if one runs the nslookup command multiple times there might be a change in the IP address, so no need to worry!

nslookup google.com

nslookup facebook.com

Step-3

Now we need to check for existing default routes and delete them because we need to add our own rule.

So to look for the existing routes -

route -n

And to delete the default route that is 0.0.0.0

route del -net 0.0.0.0

So, after deleting if we again run route -n command, one want finds 0.0.0.0 destination. This means that our connection is broken with the outside world. So, if we try to ping again to Google or Facebook it won't be possible. The same is illustrated in the images below-

Step-4

So, it's now time to add your own rule. Our motto was to create a system that only ping to GOOGLE but not FACEBOOK. So for adding rule use the command below

route add -net IP(of google) netmask _._._._ gw _._._._ NICname

If you remember we earlier used the nslookup command, pick the IP address from there.

Now let's try to verify our system.

First, it was not pinging to google.com because Google has multiple IP’s and there are pretty high chances it was pinging to some other IP address. So when we specified the exact IP it was fine. And also the system was not able to ping Facebook.

Hence, practical successfully performed !!

--

--