Pinging Google But not Facebook

Chetna Manku
4 min readDec 21, 2020

--

Have you ever wondered how your system is able to connect to Google or Facebook?? And is it possible to only connect to Google but not to Facebook?

The answer is yes! Using concepts of Networking, anyone can do this.

Some Basic Concepts of Networking:

What is IP Address?

IP address stands for internet protocol address; it is an identifying number that is associated with a specific computer or computer network.

What is PING command?

Ping is a command-line utility, available on any operating system with network connectivity, that acts as a test to see if a networked device is reachable.

What is Routing Table?

A routing table is a set of rules, 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.

A routing table defines the single route available to a typical local host and to determine whether to send packets to the default gateway router.

The following steps are performed on RHEL8.

STEP-1: CHECK EXISTING ROUTES IN THE ROUTING TABLE

  • To see routing table, run this command :
# route -n
Output of route command

What is default route 0.0.0.0 ?

Each computer network has a default route for each network card. This will create a 0.0.0.0 route for such card. The address 0.0.0.0 generally means “any address”.

This is the reason why your system is able to connect to the Google and Facebook on Internet.

STEP-2: CHECK CONNECTIVITY TO GOOGLE AND FACEBOOK USING PING COMMAND

# ping www.google.com
# ping www.facebook.com
output of pinging Google
output of pinging Facebook
  • System is able to ping both Google and Facebook using their IP address.
  • You can also use the following command to know the IP Addresses.
# nslookup www.google.com
# nslookup www.facebook.com
output of nslookup command.
  • IP of Google is 172.217.160.228
  • IP of Facebook is 157.240.198.35

STEP-3: DELETE THE EXISTING DEFAULT ROUTE FROM THE ROUTING TABLE

  • Let’s delete this default route from our routing table using command:
# route del -net 0.0.0.0
  • After deleting this default route, now system is unable to connect to Google and Facebook.

STEP-4: ADD A NEW ROUTE IN ROUTING TABLE OF NETWORK RANGE ONLY FOR GOOGLE IP

  • To add route in routing table, use command:
# route add -net <network_address> netmask <netmask_addess> gw      <gateway> <network_interface>
  • To ping Google, add the Network range in the routing table, so that only Google’s IP will able to connect.
  • The destination address ( 172.217.160.228 ) is not within the network range. So, we also need to specify the gateway address.
output displaying added route in routing table
  • Google IP (172.217.160.228) comes in the Network (172.217.160.0–255) with the subnet mask of 255.255.255.0
  • 192.168.0.1 is the default gateway IP through which this system will reach the internet.
  • And enp0s3 is the network interface.

What is default gateway? Why it is needed?

The Default Gateway is an IP address of the Router, which is responsible to forward packets to another network. Usually, a gateway provides internet access to the network devices/computers.

The network packets that are not within the network has to be forwarded to this default gateway address.

What happens when your system don’t have default gateway?

If a computer doesn’t have default gateway it will not be able to access the Internet or any other network. Without it, the network is isolated from the outside.

STEP-5: TRY TO PING GOGLE AND FACEBOOK

  • Now using PING command, check the connectivity to Google and Facebook.
output of pinging to Google and Facebook IP
  • You can see this system is only able to ping IP address of Google but not of Facebook.

Now, following the same steps you can also do the similar task — Only Ping to Facebook but not to Google.

To restore default routes, you just need to disconnect your system’s wire. And again connect it to the internet.

--

--

Chetna Manku
Chetna Manku

No responses yet