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

Shruti
4 min readMar 12, 2021

Before moving ahead we need to understand some basic terminologies of networking:

Routing Table:

A routing table is like a database which resides in every system holding the routes to particular network destinations. This information contains the topology of the network close to it .Whenever we ping to some ip address called as destination , our system always checks the routing table and checks whether that ip range called as netmask is present there or not, if that range is present there then only system will generate packets to destination ip otherwise not.

Gateway:

A gateway is a node on a network that serves as an entrance to another network. When we send packets from our system to some destisation ip address,Gateway is the one which works as an intermidiate and transfer our packets to the destination.

A Gateway is also called as ‘Protocol Converter’ because it can convert the data packets as per the destination network protocol requirement. It can also translate the data format as per the destination needs or architecture.

So now lets start the practical, I am using REHL 8 linux for this practical.

Netnetmasks :

Netmasks refer to classes of IP addresses. They are used to define a range of IP addresses that can be used by an ISP or other organization.

Step 1:

route -n will show the routing table of the system. if has 2 rules related to network card enp0s3

First rule of routing table states that:

0.0.0.0 in destination column means we can connect to any destination public ip in the world like google, facebook, instagram etc. with deafault gateway 10.0.2.2

Routing Table
pinging to google
pinging to facebook

Step 2:

nslookup www.google.com command will help us to get the ip of google from our local dns server, As we can see the ip is 216.58.196.100 , we will use this ip while adding rule.

ip of google

Step 3:

By route del -net 0.0.0.0 command we are deleting the 1st rule of routing table, with the help of which we were able to connect to the any public destination ip like google, facebook etc.

deleting the rule in routing table

Now we can check the same in routing table, weather the rule is deleted or not, as we can see rule is deleted.

rule deleted

Now, we will check whether we are still able to ping to google or facebook, As we can clearly see , it is showing network unreachable because we deleted the rule.

checking the connectivity for google and facebook

Step 4:

Now we will add a new rule in routing table , after which our system will able to ping to google via gateway 10.0.2.2 and network card enp0s3.

Note: You can get the default gateway ip by using cat /etc/resolv.conf command.

adding a new rule in routing table

We can see in routing table new rule is added in a third row.

rule added

Now , we an see in the below 2 images, that we are able to ping to google but not facebook.

WOW!! WE DID IT.

--

--