Setup to be able to ping google and not facebook

What do you mean by ping?

Ping is a network diagnostic tool used primarily to test the connectivity between two nodes or devices. To ping a destination node, an Internet Control Message Protocol (ICMP) echo request packet is sent to that node. If a connection is available, the destination node responds with an echo reply. Ping calculates the round-trip time of the data packet’s route from its source to the destination and back and determines whether any packets were lost during the trip.

What is Routing Table?

A routing table is a set of rules, often viewed in a table format, that is used to determine the direction of data packets over an Internet Protocol(IP). All IP-enabled devices use routing tables. Routing tables can be maintained manually or dynamically.

A basic routing table includes the following information:

What is a Gateway?

A network gateway joins two networks so the devices on one network can communicate with the devices on another network. Without gateways, you couldn’t be able to access the internet, communicate and send data back and forth. A gateway can be implemented completely in software, hardware, or a combination of both. Because a network gateway by definition appears at the edge of a network, related capabilities such as firewalls and proxy servers tend to be integrated with it.

Let's start the practical. To be able to ping a set of ip addresses and not others we need to make few changes in the routing table. This can be done in few easy steps in RHEL8.

First, let us check the connectivity by pinging both google and Facebook. Also, check the routing table. It contains a rule where the device can connect to all other ips (

If the ping is not working, first, check the network connectivity and then use the command-

$ifconfig enp0s3 down

$ifconfig enp0s3 up

Now find ip address of google and Facebook by using nslookup commands.

We need to delete the existing rule and add a rule, where the connectivity is established only for google. for deleting the existing rule use command

$route del -net <ip>

$route add -net <ip> netmask <netmask> gw <gateway> <card>

here we need to provide the network name which is 24 bits of Google’s ip and the remaining 0. the netmask will be which can also be given as /24 and the default gateway.

We can now successfully ping google and not Facebook from the same system.