Customized Networking!!!

How to customize networking so that we can ping Facebook but not Google?

Welcome, Everyone!!! I hope you are having a great day.

This blog is about how we can customize the rules in our networking routing table so that we can connect to the network range IP’s which we want. So let's get started…

First, let's understand something about the vocabulary we will be using.

IP address: IP address are the number which uniquely identifies any devices in the world. Mobile Phone, Computer, Routers, everything have a unique IP address. IP addresses are made up of 4 octet binary numbers. For an easy understanding, we change the binary number to hexadecimal and use/read it—each octet in IP range from 0 to 255.

Netmask: Netmask is a 32-bit “mask” used to divide an IP address into subnets and specify the network’s available hosts. In a netmask, two bits are always automatically assigned. For example, in 255.255. 225.0, “0” is the assigned network address.

Internet Gateway: A gateway is a node (router) in a computer network, a key stopping point for data on its way to or from other networks. Internet connections at home, the gateway is the Internet Service Provider that gives you access to the entire Internet.

Routing Table: In computer networking, a routing table is a data table stored in a router or a network host that lists the routes to particular network destinations. In some cases, metrics (distances) are associated with those routes.

For our implementation, we will try to ping Google and Facebook from our local computer, and we then delete the route to the internet and then create our own route rule so that we can visit only specific IP’s.

Let's try to ping Facebook and Google to check if we are connected to them or not.

In the above image, we can see that we are pinging Facebook and Google, and we are receiving packages means we can exchange packages. When we use “,” we are pining the google IP address is the DNS, a name given to the IP for better understanding. Google has various IPs as they have a lot of systems and servers. is also one of the IP of Google. The same goes for Facebook. We can see the IP of Google and Facebook, which we are pinging in our command output.


Now we will check the rules which are present in our routing tables. To check to route, we can use the command:

# route -n

Above, we can see the rules in the routing table of our router. The destination is the IP we are going to, and as per the first rule, we can see that we can go to any IP. The IP means that it is a universal IP and indicates all IP’s. And the Gateway is the IP of our router, which will take us to the Internet9which includes google and Facebook also). The Genmask is the mask of the IP, which indicated the network range, and that also we can see, which means all the network ranges.

Now we will delete this rule so that we will not be connected with the internet, and in the below image, we can see we used the command to delete the rule from the routing table:

# route del -net 

As we don’t have any rules that connect us to the internet, let's see what will happen if we ping Google and Facebook.

We can see that it is saying network unreachable, which means we cannot connect to them.

Now, let’s add a rule from which we can only connect to Facebook. We can use the command.

# route add -net gw
# route add -net netmask gw

Here, the first IP( is the network name of Facebook. For better availability, we took a bigger range of networks. And the “/16” is the netmask written in prefix form or is as in the second command. And `gw` is our Internet Gateway, i.e. ( And we added this rule to our routing table.

We can see our routing table below in our image with the new rule which we just added.

Now when we try to ping, let’s see what will happen.

NOTE: We just changed the IPv4 routing table and created rule for it so we will try to ping the IPv4 of Facebook and Google as they have many IP and we might end up pinging IPv6. We can delete the table of IPv6 also(but that’s not a good idea).

As in the above image, we can see that when we try to ping “,” it is saying Network Unreachable, and when we ping “,” we can exchange packets.

Now, similarly, let's add the rules for Google and check if we can ping.

We have added a rule for the Google IP network range, and we can see that there is one more rule in our routing table. So let's try to ping Google and see the output.

As in the above output, we can see that we are exchanging packets.

In conclusion, we have successfully customized the rules in our routing table, and we can create our own required routing rules. I hope I have presented my idea clearly, and if you have any doubt or want to contact me feel free to ping me on my LinkedIn.

Thank You for your time. Have a Good Day.

I blog about ML, Big Data, Cloud Computing. And improving to be the best.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store