Configure Routing Table to Access some Specific Website only

Configure Routing Table to Access some Specific Website only

TASK: Create a Setup so that you can ping google but not able to ping Facebook from same system.

We will launch a RHEL8 OS on our local VM for this setup.

This Setup will helpful when you want to block some website or you don't want to anyone can access these sites from your system then this setup will be really helpful for you.

First use the "ifconfig" command to know the ethernet address of the system on which we wanna to configure this setup.

No alt text provided for this image

Now using "nslookup" command we will try to find IP address of google and Facebook.

nslookup www.google.com
nslookup www.facebook.com


No alt text provided for this image

WE can clearly see the IP of Google and IP of Facebook here.

Now we will try to visualize our routing table.

route -n
No alt text provided for this image

In routing table we can see that first destination is "0.0.0.0" with Genmask "0.0.0.0" that means that by this system we can go anywhere in the world.

So we need to cut this connection first because in this system we want to go to Google only.

route delete -net 0.0.0.0
route -n
No alt text provided for this image

Now after disconnection the outer world connection we will add google IP address in our routing table.

route add -net 172.217.0.0 netmask 255.255.0.0 gw 192.168.43.1 ens160

#172.217.166.68 i found through nslookup command so i made last two octet 0 so we can get all possibility of google connections.
#I used netmask 255.255.0.0 here to get 2^16 combination so it can connect google easily. 
#192.168.43.1 is my IP address you can check your's from routing table
#ens160 is my ethernet card you can check yours from "ifconfig" command


No alt text provided for this image

Now we will use ping command to ping to Google and Facebook.

No alt text provided for this image

We can clearly see that IP of Facebook is not reachable but Google's IP is!!

We can confirm this on browser also.

No alt text provided for this image


To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics