Skip to content

Using Routes

Routing is the means by which IP packets are sent from one point to another, though a series of gateways or routers. All internet protocols use routing in this way to send IP packets or datagrams through the internet.

Information on how packets are forwarded are stored in a kernel structure called a routing table. View the routing table using either route -n or netstat -r.

Fields

  • Destination: the destination network. Note that 0.0.0.0 (sometimes shown an default) identifies all possible IP addresses not already classified in the routing table.
  • Gateway: The defined gateway for the associated network interface. An asterisks * means that no forwarding gateway is required.
  • Genmask: This is the netmask for the network interface.
  • Flags: U = route is up, G = the specified gateway is used for the interface.
  • Metric: The network resistance, which can be used to prioritize interfaces.

Example

sh
# Add a route
route add -net 10.10.1.0 netmask 255.255.0.0 dev eth0
# Add a default gateway
route add default gw 10.10.1.1
# Delete entry from routing table
route del -net 10.10.1.0
# Add a route
route add -net 10.10.1.0 netmask 255.255.0.0 dev eth0
# Add a default gateway
route add default gw 10.10.1.1
# Delete entry from routing table
route del -net 10.10.1.0

Notes:

  • If an IP ends in x.x.x.0, this refers to the 'network'. Recall, 0 means any available value on the quadrant of the IP address.
  • If an IP ends in x.x.x.1, it is likely the gateway for the associated network.

ADDITIONAL RESOURCES