Routing table

The router strips off the ethernet frame and drops the IP packet into a queue for processing. Then the router inspects each packet’s destination IP address and sends the packet out the correct port.

  • Destination LAN IP: A defined network ID

  • Subnet Mask: To define a network ID you need a subnet mask

  • Gateway: The IP address for the next hop router. If the network ID is directly connected to the router, then you don’t need a gateway. If there’s no gateway needed most routing tables have either 0.0.0.0 or On-Link here.

  • Interface: Which port to use to route an IP packet

  • Default route: Has destination lan IP and subnet mask 0.0.0.0. Unless a packet matches another route in the table the router will use the default route.

Commands #

Windows: route print Linux: route netstat -r

[akraker@localhost ~]$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         modem.Home      0.0.0.0         UG    100    0        0 enp0s31f6
default         modem.Home      0.0.0.0         UG    600    0        0 wlp4s0
192.168.0.0     0.0.0.0         255.255.255.0   U     100    0        0 enp0s31f6
192.168.0.0     0.0.0.0         255.255.255.0   U     600    0        0 wlp4s0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

Metric #

This is a relative value that defines the cost of using a certain route. The router will always use the lowest cost route available.