The Routing Table

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.

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”.

--

--

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