Creating a network setup that can ping Google but unable to ping facebook from the same system
We will follow step by step to create this setup.
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.
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.
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#53Non-authoritative answer:
Address: 2a03:2880:f1ff:83:face:b00c:0:25deNon-authoritative answer:
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.
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 22.214.171.124 gw 192.168.43.1 netmask 255.255.224.0 enp0s3
the ip we got from the ‘nslookup’ command of the google(126.96.36.199) is a part of range of google ip(188.8.131.52 — 184.108.40.206), so the netmask for this ip range will be 255.255.224.0, so our destination will be 220.127.116.11 and our gateway will be 192.168.43.1.
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.
We have successfully created the setup that can ping google but unable to ping facebook.