This Blog contains a demonstration of a setup that can ping Google but not Facebook.
We can achieve this with the help of a Routing Table, so let's first discuss what Routing Table is.
A routing table is a set of rules, often viewed in a table format, that is used to determine where data packets traveling over an Internet Protocol (IP). All IP-enabled devices, including routers and switches, use routing tables. The image below shows the Routing Table:
Now we have discussed the Routing Table so let's start with the demonstration...
First let's check the routing table in our system
To check the routing table, use the command route -n
Here you can see the routing table with the default rule that is destination 0.0.0.0, this means we can connect to anyone.
Netmask is a 32-bit binary mask used to divide an IP address into subnets and specify the network's available hosts.
Iface is network card name and in my case network card is enp0s3.
Now let's check are, we able to ping Google
In order to ping Google use the command ping www.google.com
Here you can see we are able to ping it which means we have network connectivity.
Now let's check are. we able to ping Facebook
In order to ping Facebook use the command ping www.facebook.com
Here you can see we can ping Facebook...
Now let's check the IP of the Google
To check the google IP use command nslookup www.google.com
Here you can see an address that's the IP of google.
Now delete the default routing rule
To Delete routing rule use command route -net del 0.0.0.0 enp0s3
Now add google IP to the routing table
Write Google Ip in Destination and gateway will be localhost and write netmask 255.255.255.0
Now check if we can ping Google
To ping, google use the command ping www.google.com
Here you can see, we are able to ping Google
Now check if we can ping Facebook
Here you can see, now we are not able to ping Facebook but we are able to ping google.
So, that's how we can set up the network using the Routing Table.