The Routing Table

Karan Agrawal
3 min readJan 13, 2021

--

A routing table is a set of rules, often viewed in a table format, that is used to determine where data packets traveling over an Internet Protocol (IP) network will be directed. All IP-enabled devices, including routers and switches, use routing tables. See below a Routing Table:

The entry corresponding to the default gateway configuration is a network destination of 0.0.0.0 with a network mask (netmask) of 0.0.0.0. The Subnet Mask of the default route is always 255.255.255.255.

Each entry in the routing table consists of the following entries:

  1. Network ID: The network ID or destination corresponding to the route.
  2. Subnet Mask: The mask that is used to match a destination IP address to the network ID.
  3. Next Hop: The IP address to which the packet is forwarded
  4. Outgoing Interface: Outgoing interface the packet should go out to reach the destination network.
  5. Metric: A common use of the metric is to indicate the minimum number of hops (routers crossed) to the network ID.

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

  • Check Routing Table using command, “route -n”.
  • Try to ping google.com and facebook.com. You must be able to ping them. Write down their IP’s.
  • Now Delete the Default Gateway using the command, “route del-net 0.0.0.0”.
  • Now try to ping google.com and facebook.com. You must not be able to ping them.
  • Now add a rule in the routing table so that you can ping google.com but not facebook.com by using the command, route add -net <google’s IP> netmask 255.255.255.0 gw <gateway-IP> enp0s3”.
  • Now you will be able to ping google.com but not facebook.com.

Note: Add the default rule back to the routing table so that you can connect to the Internet by using the command, “route add -net 0.0.0.0 netmask 0.0.0.0 gw <gateway-IP> enp0s3”.

--

--

Karan Agrawal
Karan Agrawal

No responses yet