Setup you can Ping Google but not Facebook

Using Routing table

Ranga Mani kumar
4 min readMar 10, 2021

Introduction :

Routing table :

Routing table is a data table and contains rules which determines whether to create a network packet to a particular destination. If the rule is there in the routing table that you can send packets, you can send. The routing table present in all devices. We can create routing table accordingly to whom we have to create and for whom we don’t have to create. After creating routing table, the OS can identify the rules. So, accordingly it will create.

Network Name :

Network Name is actually an IP and the first address of the Network which actually tells about the Network range with respect to Netmask. It is the reserved IP of the Network. We can able to send a packet within the Network name or Network range which we create in routing table. It is also called as Network ID.

Netmask :

Netmask actually tells the range of IPs in the network starting from Network name. Netmask can also be called as Subnet mask or Genmask (But there is a little difference betweeen Netmask and Subentmask but logic wise both are same). The Network name with Netmask is called as Subnet ID. The Subnet ID is represented as Network_name/Netmask. For ex: The IP address of the system is 192.43.56.180 . In this the network name can be 192.43.56.0 and netmask is 255.255.255.0 and whole can be represented as 192.43.56.0/255.255.255.0 or 192.43.56.0/24 and this is called Subnet ID. The last ocatate which occupies in the Network range is called Host ID. In the example the 180 is called host ID of 192.43.56.0/24 network.

Internet Gateway :

Internet Gateway is a router which can connects your network to Internet. It may be Physical device or Virtual device.

Now, Let’s go to our task

Task :

We want a setup and create a routing table in such a way that we can ping Google but not Facebook.

Step -1 : First, check the routing table what is there and try to ping www.google.com and www.facebook.com

route -n //for checking routing table
ping www.google.com -4 //Using routing table of IPV4
ping www.facebook.com -4 //Using routing table of IPV4

Here my main Network card is enp0s3 and Internet Gateway is 192.168.43.1 and using this only Iam able to connect Internet. Destination Network range or Network Name is 0.0.0.0 that means that I can create packets to any IP address in the world. No resrtictions in creating packets for any device and my Genmsk or Netmask is also 0.0.0.0 that means no range, any IP in the world.

So I can ping www.google.com and www.facebook.com that means Iam able to create packets.

Here the IP Adress of www.google.com is 142.250.183.100 and www.facebook.com is 69.171.250.35

Step-2 : First, we delete the rule of destination Network Name 0.0.0.0

route del -net 0.0.0.0

Step-3 : Now, we have to add the rule in routing table that you can ping www.google.com

route add -net <network_name> netmask <netmask> gw <Internet_gateway> <network_card>route add -net 142.250.183.0 genmask 255.255.255.0 gw 192.168.43.1 enp0s3

Here the IP of www.google.com is 143.250.183.100 but we have to take Network name with respect to Netmask. So we took 142.250.183.0/255.255.255.0

Step-4 : Now, let’s try to ping www.google.com and www.facebook.com

Here you can see, Iam able to create packets and can ping www.google.com but Iam not able to ping and not able to even create packets for www.facebook.com beacause it is out of the network range according to the routing table. It should be within the Network name to create packets.

Thankyou…

Keep learning…

Keep sharing…

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response