Ping Google but not Facebook-editing Routing Table

Hello Everyone!

Today we will create a setup such that our system is able to ping Google but not Facebook by editing routes in routing table.

A routing table is the place where routing information is stored that contains routing entries or list of destinations. If a system tries to connect or ping to some other system with an IP address (destination IP), it first go to this routing table and if there is some rule which is allowing that destination then only network packets will be created otherwise not.

We can use route -n command to see rules or routes available in the routing table.

Let’s find out one of the IP addresses of google and Facebook, using nslookup command.

So, we have the two IP addresses. Now if we try to ping them we are able to do it as shown in the image below,

We were able to do so because of the first route there in the routing table which allow to connect with any IP in the world through the gateway or helps to connect to internet.

So we are deleting this route,

Now if we try to ping google or facebook IP, it will directly say unreachable without creating any packets because no such route is available in the routing table.

We are adding a route now so that only google’s IP address is pingable.

In other words we adding route for destination IP in range of 172.217.160.0/24 for our network card enp0s3 and the gateway IP is same as before

After this, if we now try to ping IP of google then it is pinging but the IP of Facebook is unreachable as shown below in the screenshot.

Finally, we have done this setup by editing the routes and it is working.

Thank You!

Tech and Programming, MLOps, DevOps Assembly Lines, Hybrid Multi Cloud, Flutter and Ansible Automation