Can I ping to Google but Not Facebook?
Ever Imagine you can control the server connection of your system. This means you can ping Google but not to Facebook at the same time.
Ya… I am saying right you can easily do this and today I am going to discuss with you how we can actually set an environment where our system will be able to connect with Google but not with Facebook.
In this small hack, we are going to use some simple networking concepts. Don’t worry if you don’t have any knowledge about networking. We are going to discuss all with very basics.
- An operating system
- A stable internet connection
I am going to work on RedHat as our operating system, you can choose whatever you want.
Before jumping into the practical confirm that you have a stable connection by pinging to Google or Facebook or any other public IP.
Procedure to setup:
Step-1: Check your routing table
In RedHat OS, we have the following command to get info about our routing table.
The routing table is a data table stored in the network host(in our case it is our VM) that lists the routes to particular network destinations.
In simpler manner we can understand that routing table keep the information of path of the destination where that network provider can connect.
You will find there is a row having 0.0.0.0 destination that means it can connect to anywhere in the world. Now we just have to change it with Google IP so we can connect only with Google.
Step-2: Get the IP of google
Using below command you can easily find the address of google.
Step-3: Remove 0.0.0.0 destination
Once we get the IP of Google, our next step is to delete the route table info allowing all traffic to connect, i.e. 0.0.0.0. We can easily remove that by using the following command.
route del -net 0.0.0.0
Now you don’t have permission to connect with the public world, you can check using
ping google.com or ping facebook.com
Step-4: Add google IP to our routing table
To add the google IP we will use following command
route add -net 22.214.171.124 netmask 255.255.255.0 gw 192.168.43.1
NOTE: In my case Google IP is 126.96.36.199 and I place 0 at the end because if any other IP comes in the range of this can connect, due to multiple servers of Google.
◾For gw(Gateway), I looked in the detail of the routing table where we don’t have deleted our row.
Step-5: Again ping to both
Once the routing table is updated you can check using
You can now try to ping Google and Facebook again and now what you will find you will easily connect with Google but not with Facebook.
We have completed our task.
In this task, we have made an environment where we can connect with Google but not with Facebook. Similarly, we can add multiple routes.
Comment down below on how the task was. Share with your friends. Stay connected with us for more amazing tasks.