How to Setup to Ping Google but not able to Ping Facebook from the same System

Let’s create the above-mentioned setup and I will walk you through step by step.

Note: This setup is done perfectly with Linux-based operating systems, so before performing this operation make sure you are using Linux operating systems like Ubuntu, Linux-mint, etc.

Before we begin, you have to understand some basic concepts of networking.

What is ping?

A ping is a signal sent to a host(or another computer) that requests a response.

It serves two primary purposes:

1) to check if the host is available and

2) to measure how long the response takes.

A ping request can be performed using a ping command, which is a standard command in most command-line interfaces. Several network utilities provide a ping feature, which allows you to ping a server by simply entering the IP address or domain name.

pinging google means checking whether we able to connect with google server or not

For example,

To perform a ping command from a command-line interface, simply type “ping” followed by the IP address or domain name of the host you want to ping (e.g., ping

What is routing tables?
A routing table is a set of rules, often viewed in table format, that is used to determine where data packets traveling over an Internet Protocol (IP) network will be directed. All IP-enabled devices, including routers and switches, use routing tables. See below a Routing Table:

Destination      Subnet mask         Interface Eth0 Eth1 Eth3
default Eth2

The entry corresponding to the default gateway configuration is a network destination of with a network mask (netmask) of The Subnet Mask of the default route is always

To show the routing table, type: route -n

Let’s, create our setup

Here, I am using a Linux operating system that is able to ping to both website

Step1: Let’s check whether we are able to ping to both website or not

Type: ping to ping with Google

Type: ping to ping with Facebook

Check Routing Table

Step2: To view your current routing table,

Type: route -n

Step3: Now, check the IP of google using the nslookup command

Type: nslookup to get the Google IP

Type: nslookup to get the Facebook IP

Step4: Now, delete the default routing rule from the routing table

Type: route del -net to delete default gateway rule

We have just deleted the internet gateway rule from the routing table. Now if you try to ping google or anything it won’t ping.

That is we just lost our internet connection by deleting the routing rule.

Step5: Now, we create a rule for only ping but not Facebook

Type: route add -net netmask gw enp0s3

and you can see the rule is attached to the routing table by typing: route -n

That means,

route add -net ip_of_google_that_we_get_earlier netmask gw google_server_ip your_network_interface_name(ie, here in this case, enpos3)

To get the google_ip and google_Server_ip:

Type: nslookup

To get the network_interface_name:

Type: ifconfig

It displays information about all network interfaces currently in operation and the output resembles the following:

Step6: Now, try to ping to google

Type: ping, now its start working

Now let's see if we can ping Facebook, it will not work because we add the rule only for connecting with google, not able to connect with any other websites.

Hope you like it.

Thank You!

Python Enthusiast