Let's ping Google but not Facebook
Network: It is the well-established connection between two or more nodes or systems or computers for communication. The communication may have any reason. Like the send and receive the data, resource sharing, etc.
There are a few prerequisites that needed for the communication between two devices:
- Wired/wireless connection
- NIC (Network Interface Card) in both the devices
- IP addresses on both the sides
- Network name
- Switch or router
Wired/wireless connection: Usually, we have ethernet cables to connect with LAN, and it is an example of a wired connection. We connect one device with another through HotSpot, Wifi, and Bluetooth are examples of wireless connections.
NIC: NIC stands for Network Interface Card. It is inbuilt with each networking device and helps to connect one device to another. We can think that if our computers do not have NIC in them, we can’t connect with any network.
IP address: IP stands for Internet Protocol. An IP address is the device’s address inside a network. Each device has its unique IP in public network and maybe same as other inside different private network. 192.168.13.101 is an example of an IP address, where each octet ranges from 0 to 255. We see the domain name, those are also the IP address, but for easy access and to remember it, we give it some pretty name that can remember like www.google.com or www.facebook.com.
Network name: The network name is the range of the network that is similar for all the devices inside the network. It is used to reference a particular computer network.
Switch: The switch is a networking device that is used to connect one device with another inside the same network range. Eg. all the devices under the network range or subnet 192.168.0.0/16. In this range (256 * 256), IP can be produced, and that much IPs can be connected with many switches.
Router: A router is a device used to connect one network to make an extensive network and better communication. Since switches could not connect to two different networks, so the router came into use. We can use the internet (Network of networks) because our devices have routers to communicate with the other networks.
To check the connection between the two networks, we ping from the source IP to the destination IP. Usually, if one can ping google can also ping Facebook. But, here I am, trying to do some configuration so that my computer can ping google but not Facebook. It is a handy case. Just imagine you have a startup and you have employees to access the internet on desktop PCs. If we do such a configuration, the employees will not waste their time on Facebook by login in through that PC.
- To see the routing table
Command: “route -n”

2. Find the IPs of www.google.com and www.facebook.com
Command: “nslookup www.google.com” and “nslookup www.facebook.com”

3. We need to delete the by default route (0.0.0.0/0) that connects this system to the other network. The default gateway must be deleted so that the system can’t connect to any other network outside the system network. In our case, the Gateway of the default route is 168.192.43.140, which helps to send the packets from the source system to google when we were pinging. When we delete this route, we will be able to ping neither Google (172.217.167.4) nor Facebook (69.171.250.35).

4. Now we will add the netmask of the IP of Google only to the routing table and after that, we will be able to ping Google. Since the netmask of Facebook will not be added to the routing table so we will not be able to ping to Facebook.
Comand: route add -net 172.217.167.0 netmask 255.255.255.0 gw 192.168.43.140 enp0s3
Here, I am using the range 172.217.167.0 instead of using the particular IP of Google and the netmask value is 255.255.255.0. It means the route can connect with all the IPs that come under the range 172.217.167.0/24. And I am taking the Gateway as 192.168.43.140 which was the default gateway for this particular system and it is like the entering point of all the packets that are coming from some other networks.

Now, if we want to connect with Facebook as well then we can add the range and netmask of facebook to the routing table as well, and then we will be able to ping to Facebook as well.
Hope you enjoyed this small task based on networking. Thank you!!!