Ping Google But Not Facebook

Concepts of Network Routing Table.

In this article, we will see the concepts of the routing table. Also how we can set up the routing table in such a way that you can ping google but not ping Facebook using IPv4.

So firstly let's Understand the basic terminology of Networking

Network

A network consists of two or more computers that are linked in order to share resources, exchange files, or allow electronic communications.

Network Ping

Ping is a program used to check internet connectivity between two network devices.

Network Packet

The segments that are transferred over the network are called network Packets. This packet consists of a header part and Data Part. Data Part is called PayLoad.

IPv4 address

An Internet Protocol address is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication.

To see the internet protocol address run nslookup command.

nslookup www.google.com

now press enters it will automatically open google's website.

This proves that any number that can fit in 32bit is a valid IPv4 address.

Wrong Concept/Myth: ___.___.___.___ → IP in this format is only valid IP.

Netmask/Genmask

A netmask is a 32-bit binary mask used to divide an IP address into subnets and specify the network’s available hosts. It defines how many hosts we can connect to a network.

e.g. 192.168.43.0/29 →32–29=3, 2³=8

This network contains a maximum of 8 host and 2 of them are reserved.

Reserved Addresses:

  • Network Name: First IP of network i.e.“0”
  • Broadcast address: Last IP of network i.e.“255”

Network card(Ethernet Card/NIC)

A network interface controller is a computer hardware component that connects a computer to a computer network.

Routing Table

In computer networking, a routing table is a data table stored in a router or a network host that lists the routes to particular network destinations, and in some cases, metrics (distances) associated with those routes. The routing table contains information about the topology of the network immediately around it.

Let's start with the Setup

First, we will check whether we have internet connectivity and can be able to ping google and Facebook.

ping -c 2 google.com
ping -c 2 facebook.com
Ping to Google and Facebook

we can see that, we can ping google and Facebook.

Routing Table

We can ping google and Facebook due to the routing table rule where the destination[Network Name] is 0.0.0.0 and the genmask is 0.0.0.0. Also, we can represent it in this way 0.0.0.0/0. This becomes 32–0=32 and that gives host id 2³² which means every Ipv4 in the world comes in this network range. here gateway IP is 192.168.43.1 helps to connect to the internet.

To perform the setup we need Ip addresses of Google and Facebook and for this

nslookup google.com
nslookup facebook.com
IP address

The Next Step is to remove destination network 0.0.0.0

route del -net 0.0.0.0
Updated Routing Table

Now let’s check ping

Ping Using IPV4

The above picture has a great meaning, when we run the ping command first Operating system goes to the routing table and check every subnet/rule and if the IP of source[eg. google] comes in the range of any subnets in the routing table then the only packet is created. Otherwise, packets are not created and gives the output network is unreachable.

Now we have to add a rule in such a way that the IP address of Google comes in a range of network. For this

route add -net 172.217.0.0 netmask 255.255.0.0 gw 192.168.43.1

Check Connectivity with the ping command.

here -4 means using routing table of IPv4 address.

Ping Google
Ping Facebook

As we can see in the above picture, we can ping google. The Operating System only creates the packets for the google server because the IP address of the Google server comes in a range of routing table rules. Any packet creation is done after checking the routing table rules.

To reset your environment back to normal, you only need to reconnect your network.

I hope this article helps you to understand the importance of the networking and routing table.

Thanks for reading this article!

Aspiring Cloud DevOps Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store