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:
- Network ID: The network ID or destination corresponding to the route.
- Subnet Mask: The mask that is used to match a destination IP address to the network ID.
- Next Hop: The IP address to which the packet is forwarded
- Outgoing Interface: Outgoing interface the packet should go out to reach the destination network.
- 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”.