🔰 Create a Setup so that you can ping google but not able to ping Facebook from the same system
VirtualMachine should be able to ping to google but not to FB.
Solution: give the range in RT which has google IP in it but not of FB IP.Pinging to google.com
Command: ping google.com
Working fine because 0.0.0.0 is by default added in Routing Table
Let’s first delete this rule otherwise, the system can ping any IP i.e will create the packets.
Command: route del -net 0.0.0.0
checking the table now:
Command: route -n
Let’s use one of the Google IP i.e 188.8.131.52 — one can get all the IP by ns-lookup command eg. nslookup www.google.com
Give the netmask and proving the range
Command: route add -net 184.108.40.206 netmask 255.255.2555.0 gw 192.168.0.1
Now the range has been given to create the packet. Ok
And go the gateway via nic and ping successful
Command: ping 220.127.116.11
Let’s take one the FB IP: 18.104.22.168
Command: ping 22.214.171.124
It’s unreachable: as the rule for this IP range is not added.
If we want to provide this range too, let's see how to do it.
Adding the new range
Command: route add -net 126.96.36.199 netmask 255.255.255.0 gw 192.168.0.1 enps3
So, adding always range would we very hectic
Add the gateway 192.168.0.1 for any IP in the world.
And the first IP is 0.0.0.0 and the last IP is 255.255.255.255 — all possible IP range
And the first IP is known as the network name of the range. So 0.0.0.0 means any IP. => 2³² hosts are possible. So here netmask is what /0.
0.0.0.0/0.0.0.0 => all the IP in the world. And Network name with netmask is called subnet id.
route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.0.1
Now the system can ping any IP in the world.
Let’s ping to twitter.com
Yes, it's working……………………………