Create a Setup such that you can Ping Google But not Facebook from Same System…
Hello Guys,
Today I am up with a Task to implement a Setup using which you can only Ping Google but not Facebook. The setup we are going to implement is given above, please refer the above image.
What are the requirements to Ping any IP ?
Pinging some IP means sending packet to that IP. In that case you are the Source and IP to Ping is Destination IP. In Our Task Our System is Source and Google and Facebook are Destinations.
To ping some IP, we have to make sure that it’s entry is made in Routing Table. 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 associated with those routes.
To see Routing Table we have Command In Linux :
route -n
# To implement Task We follow these Steps :=
- Check whether Google and Facebook are Pingable initially :
ping www.google.com
ping www.facebook.com
2. Delete 0.0.0.0 rule from Routing Table :
We have to delete rule 0.0.0.0 because this rule allows us to send packet to any IP in the world which is exposed publically. So,delete that Rule using command:
route del -net 0.0.0.0 netmask 255.255.255.0
3. Ping Google and Facebook to check :
ping www.google.com
ping www.facebook.com
See, We cannot ping to Google as well as Facebook. That means our rule 0.0.0.0 is successfully Deleted.
4. See IP of Google :
To see IP of Google we use “nslookup” Command.
nslookup www.google.com
5. Add Route to Google in Routing Table :
To do so we use command “route add ”.
route add -net 142.250.0.0 netmask 255.255.0.0 gw 192.168.1.1 enp0s3
Here we have to specify the domain IP of google as it’s IP changes everyime we hit it so, I passed 142.250.0.0 . We have to also specify the Netmask which will be 255.255.0.0 according to the IP.
“gw” is the Internet Gateway IP which is also called as router IP which can be seen using Command:
ip route | grep default
After Hitting Enter your Route is added in Routing Table shown below :
6. Ping Google and Facebook :
ping www.google.com
ping www.facebook.com
See, We can Ping to Google but not to Facebook…
We can Conclude that to send Packet to any Destination it’s path must be there in Routing Table . Otherwise we cannot access or connect to the Destination System.
So, That’s all from my side …See you all in next Blog
Do Like the Content, Share it and Follow me for more interesting Use cases…