Role of routing table in restricting and allowing websites for pinging…

Arjun Nigam
4 min readDec 14, 2020

Hey guys, as you must be aware the routing table in Linux contains the list of destinations which we have permission to access , like the internet etc.

Now the internet is a big space, we have an end number of websites to access.

So today, I am gonna show you how one can restrict its internet access to only the websites that one wants to access.

We are gonna take the example of Google and Facebook which are one of the most used websites in the world.

We are gonna restrict our access to only google and you will see you won’t be able to access any other website apart from it , be it even Facebook.

So let’s start learning :)

As you can observe in the image below , this is my routing table which has access to all of the internet.

To view the routing table:

command used: route -n

But still , let’s check if we really have access to the internet.

Command used for it: ping website_name.com

As you can observe in the images below we can ping both Google and Facebook…

Now do note your router IP before continuing with this task…

Command used: ip route

Now it’s time to remove our internet access from us…

Command used: route del -net 0.0.0.0

And as you can observe in the image below , it has been removed.

Now let’s try to ping Google and Facebook again.

And as you can observe in the image below : Network is unreachable…

Now it’s time to add some restrictions while providing our O.S with the internet.

For that :

We’re gonna need one of the Google IP.

Command used: nslookup Website_name.com

Now that we have the Google IP and also our router IP . It’s time to add the required info. to the routing table for giving our O.S. only the access to ping Google and not any other site.

Command used: route add -net Google_ip/30 gw router_ip NIC card( in my case enp0s3)

And Enter!!!

As you can observe in the image below, it has been added to the routing table.

Now it’s time to check whether we have successfully completed our task or not.

So let’s try with Google First.

And as you can observe in the image below , we are able to ping Google.

Now let’s try the same with Facebook.

And as you can observe in the image below : Network is unreachable

This is how you can give access to some websites and restrict the rest with the help of routing table.

That was all from my side. Keep learning :)

Arjun Nigam

https://www.linkedin.com/in/arjun-nigam-4728b11b8

Signing Off!!!

--

--