How to create a Setup so that you can ping Google but not able to ping Facebook from the same system?
Before creating the setup, we should understand some of the important terms.
Routing Table:- A routing table is a set of rules, stored in a router or a network host that lists the routes to particular network destinations, and in some cases, metrics (distances) associated with those routes. The routing table contains information about the topology of the network.
- Network ID:- The network ID or destination corresponding to the route.
- Subnet Mask:- The mask that is used to match a destination IP address to the network ID.
- Next Hop:- The IP address to which the packet is forwarded.
- Outgoing Interface:- Outgoing interface list (OIL) send copies of the group’s packets received on the incoming interface list for that group.
- Metric:- A common use of the metric is to indicate the minimum number of hops(routers crossed) to the network ID.
So let’s get started…
Step 1:- First, we have to check the routing table. Use the following command for the same.
Now, let us ping to Google by using the following command:-
ping -c 5 google.com
To ping Facebook, use the following command:-
ping -c 5 facebook.com
Step 2:- Now, we have to delete the default gateway (i.e., 0.0.0.0).Use the following command for the same:-
route del -net 0.0.0.0
Now, try to ping Google and Facebook.
Step 3:- Next, we have to create a new rule in the routing table so that we can ping to Google not Facebook. The command for the same is as follows:-
route add -net 126.96.36.199 netmask 255.255.255.0 gw 10.0.4.2 enp0s9
Now, again check the routing table that rule is added or not.
Rule is added in the routing table successfully.
Let’s try to ping IP of Google.
Now, try to ping IP of Facebook.
Here, you can see that we can ping the IP of Google but not able to ping the IP of Facebook.
Thank you :)