Create a Setup such that you can Ping Google But not Facebook from the Same System

Nischal Vooda
3 min readMar 26, 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

What are the requirements to Ping any IP?

Pinging some IP means sending packets to that IP. In that case, you are the Source, and IP to Ping is Destination IP. In Our Task, Our System is Source, Google and Facebook are Destinations.

To ping some IP, we have to make sure that its entry is made in Routing Table. A routing table is a data table stored in a router or a network host that lists the routes to particular network destinations, and in some cases, metrics associated with those routes.

To see the Routing Table we have Command In Linux :

route -n

Check whether Google and Facebook are Pingable initially :

ping www.google.comping www.facebook.com
ping to Google
ping to Facebook

please note down the IPs so that we can add the rule

Delete 0.0.0.0 rule from Routing Table :

We have to delete rule 0.0.0.0 because this rule allows us to send a packet to any IP in the world which is exposed publically. So, delete that Rule using the command:

route del -net 0.0.0.0 netmask 255.255.255.0

We cannot ping to Google as well as Facebook. That means our rule 0.0.0.0 is successfully Deleted.

Now Add Route to Google in Routing Table :

To do so we use the command “route add ”.

route add -net 172.217.0.0 netmask 255.255.0.0 gw 192.168.0.1 enp0s3

Here we have to specify the domain IP of google as its IP changes every time we hit it so, I passed 172.217.0.0 We have to also specify the Netmask which will be 255.255.0.0 according to the IP.

gw” is the Internet Gateway IP which is also called as router IP which can be seen using Command:

ip route | grep default

After Hitting Enter your Route is added in Routing Table shown below :

Route added

6. Ping Google and Facebook :

ping www.google.com

ping www.facebook.com

See, We can Ping to Google but not to Facebook…

We can Conclude that to send Packet to any Destination it’s path must be there in Routing Table . Otherwise we cannot access or connect to the Destination System.

So, That’s all from my side …See you all in the next Blog

Do Like the Content, Share it and Follow me for more interesting Use cases

Connect me on my LinkedIn as well.

--

--