Create a Setup so that you can ping google but not able to ping Facebook from the same system

Girija Varma
6 min readApr 23, 2021

In this article, I'm going to show you how you can create a setup where you can able to ping Google but not able to ping Facebook in the same setup.

Let's understand some basics before that,

Networking

Networking is defined as the act of making contact and exchanging information with other people, groups, and institutions to develop mutually beneficial relationships or to access and share information between computers.

A computer network comprises two or more computers that are connected either by cables (wired) or Wi-Fi (wireless) with the purpose of transmitting, exchanging, or sharing data and resources. You build a computer network using hardware (e.g., routers, switches, access points, and cables) and software (e.g., operating systems or business applications).

Some commonly used terminology in networking:

IP Address

An Internet Protocol address is a unique identifier for devices connected to a network. The unique identifier makes it possible for devices to find and communicate with each other.

An IPv4 address is a series of four eight-bit binary numbers separated by a decimal point. Although you may use any numbering system to represent a unique 32-bit number.

[0–255].[0–255].[0–255].[0–255]

but the computers store them in binary:

{01010101 01010101 01010101 01010101}

NETMASK/GENMASK

Netmask defines how “large” a network is or if you’re configuring a rule that requires an IP address and a Netmask, the Netmask will signify to what range of the Network the rule will apply to:

Sometimes you will see that a Netmask is defined by one number, e.g., 24. This number is the length of the Netmask in bits:

So, for example, a Netmask that is 24-bits long is 255.255.255.0:

A Netmask that is 16-bits long is 255.255.0.0:

And so on.

SUBNET

A subnet, or subnetwork, is a network inside a network. Subnets make networks more efficient and this process is known as Subnetting.

SUBNET ID

It is nothing but network range and netmask.

Illustration of subnet ID

NODE

A node is a connection point inside a network that can receive, send, create, or store data. Each node requires you to provide some form of identification to receive access, like an IP address. A few examples of nodes include computers, printers, modems, bridges, and switches. A node is essentially any network device that can recognize, process, and transmit information to any other network node.

Gateway

A gateway is a hardware device that acts as a “gate” between two networks. It may be a router, firewall, server, or other device that enables traffic to flow in and out of the network.

While a gateway protects the nodes within network, it also a node itself. The gateway node is considered to be on the “edge” of the network as all data must flow through it before coming in or going out of the network. It may also translate data received from outside networks into a format or protocol recognized by devices within the internal network. A router is a common type of gateway used in home networks. It allows computers within the local network to send and receive data over the Internet.

ROUTER

The router is a physical or virtual device that sends information contained in data packets between networks. Routers analyze data within the packets to determine the best way for the information to reach its ultimate destination. Routers forward data packets until they reach their destination node.

SWITCH

A switch is a device that connects other devices and manages node-to-node communication within a network, ensuring data packets reach their ultimate destination. While a router sends information between networks, a switch sends information between nodes in a single network. When discussing computer networks, ‘switching’ refers to how data is transferred between devices in a network.

PORT

A port identifies a specific connection between network devices. Each port is identified by a number. If you think of an IP address as comparable to the address of a hotel, then ports are the suites or room numbers within that hotel. Computers use port numbers to determine which application, service, or process should receive specific messages.

ROUTING TABLE

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.

In rhel-8, to check the routing table

# route -n

Routing Table

PING

A ping is a signal sent to a host 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. Most ping programs send multiple pings and provide an average of the pings at the end.

Here I’m pinging for IPv4 address

# ping -4 www.google.com

# ping -4 www.facebook.com

Now, Let’s do a fun activity where we can ping to Google but not to Facebook !!

For this you have first add this address in your routing table

# route add -net <destination_IP> netmask <netmask> gw <your_gateway> <network_card_name>

Now you have to remove this IP of the Facebook server so that from your routing table your system will not create any network packet for this particular server.

# route add -net <destination_IP> netmask <netmask> gw <your_gateway> reject <network_card_name>

After removing the Facebook server’s IP from your routing table, now this IP is blacklisted so your system will not create a packet for it.

And if you try to ping to www.facebook.com with your system you will be unable to connect but can easily ping to www.google.com

And if you try with a web browser,

Unable to connect with Facebook ✖️

Easily able to connect with Google ✔️

I hope you enjoyed this activity 😇

Thank you for remaining till the END...

--

--