Creating Setup Where Ping can Connect to the Google but not to the Facebook 👨🏼💻
Hello Geeks, In this blog, I’m going to customize my system in such a manner that it can be able to ping the Google but not Facebook…
A router is a networking device that forwards data packets between computer networks. Routers perform the traffic directing functions on the Internet. Data sent through the internet, such as a web page or email, is in the form of data packets. A packet is typically forwarded from one router to another router through the networks that constitute an internetwork (e.g. the Internet) until it reaches its destination node.
A router is connected to two or more data lines from different IP networks. When a data packet comes in on one of the lines, the router reads the network address information in the packet header to determine the ultimate destination. Then, using information in its routing table or routing policy, it directs the packet to the next network on its journey.
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. All IP-enabled devices, including routers and switches, use routing tables. The entry corresponding to the default gateway configuration is a network destination of 0.0.0.0 with a network mask (netmask) of 0.0.0.0. The Subnet Mask of default route is always 255.255.255.255 .
The primary function of a router is to forward a packet toward its destination network, which is the destination IP address of the packet. To do this, a router needs to search the routing information stored in its routing table. The routing table contains network/next hop associations. These associations tell a router that a particular destination can be optimally reached by sending the packet to a specific router that represents the next hop on the way to the final destination. The next hop association can also be the outgoing or exit interface to the final destination.
Command - route -n :- to check routing table in the system
192.168.42.129 - is the default gateway provided by the router by which can travel to internet world.
UNIVERSAL ROUTE RULE (Why we have to delete this ?)
By default router provides route rules in the table. In which first rule is defined as 0.0.0.0 , which is actually universal ip address(any ip in the world).That rule is the reason to get connect with the internet’s all the ip addresses. So we are going to delete this rule because we want to manually add ip addresses of google in this table so that it can only able to ping google.
→ route -n : to get route table information
→ route del -net 0.0.0.0 : removing route rule from table
When we delete this rule, we can’t ping to facebook or google it fails, as we have deleted universal rule from routing table.
ADDING GOOGLE IP RULE TO ROUTE TABLE
Now we have to add google’s IP address rule in the table, so that it can reach to the google.com
→ route add -net 18.104.22.168 netmask 255.255.255.0 gw 192.16842.129 enp0s3
After running above command let’s check routing table using route -n
Now Ping to Google and Facebook and see What Happens_?
→ First ping to the Google
And now, let’s try to ping to the Facebook
So as you can see our system is able to connect to the Google but not to the Facebook.