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

It is a very simple Task ,We just need to be well versed with concept of Network Name, Gateway, Netmask, and Routing Table .

Prasantmahato

--

We should know ,

What is IP ?

An internet protocol (IP) address allows computers to send and receive information. There are four types of IP addresses: public, private, static, and dynamic. An IP address allows information to be sent and received by the correct parties, which means they can also be used to track down a user’s physical location.It is an identifying number that is associated with a specific computer or computer network. When connected to the internet, the IP address allows the computers to send and receive information.

What is Netmask ?

A Netmask is a 32-bit “mask” used to divide an IP address into subnets and specify the network’s available hosts. In a netmask, two bits or two IP’s are always automatically assigned. One is assigned to Network Name and the other one is assigned to Broadcast IP .For example, in 255.255. 225.0, “0” is the assigned network address.

What is the purpose of Routing Table ?

A routing table is a database that keeps track of paths, like a map, and uses these to determine which way to forward traffic. A routing table is a data file in RAM that is used to store route information about directly connected and remote networks.

I performed this Task on Rhel8

Using network card enp0s3 whose IP is 192.168.43.146

ifconfig enp0s3

My private IP

Looking onto the Route Table of my Network Card.

By looking onto the Route Table ,We can see a rule that ,our Private IP can go to any destination with a gateway IP ,ie Router IP which Converts Private IP to Public IP by the process of Natting.

route -n

Seeing Route Table

Checking my Server has Internet connectivity as specified in the route table .

ping 8.8.8.8

Ping

To remove the Internet connection , I deleted the rule for network 0.0.0.0

route del -net 0.0.0.0

Deleting a Network rule from the Route Table

Now, We can check our server doesn’t have any Internet connectivity.

ping

Before removing the Network Rule ,We first need to know the IP of one of the server of Google and also the IP of one of the server of Facebook.

To know the IP of one of the server of Google and Facebook is simply by using

ping google.com and ping facebook.com

We get,

IP for one of the server of Google : — 216.58.196.110

IP for one of the server of Facebook : — 157.240.198.35

One of the server of Google and Facebook

Now the only thing I had done is instead of creating a rule for all networks (0.0.0.0) .I created a rule only for one of the server of Google with the gateway IP which is my Router IP and netmask I created in such a way that the Server IP of Google lies in between .

Command to create a new rule ,

route add -net 216.58.196.0 netmask 255.255.255.0 gw192.168.43.1 enp0s3

Adding and removing Network from the Route Table

Finally, We can now ping to one of the server IP of Google but same if we try with one of the server of Facebook it is not pingable .

pinging google
pinging facebook

Thankyou

Open for any query and suggestions.

--

--

No responses yet