Skip to main content

๐Ÿงญ Routing

This page provides introduction to Routing.

Overviewโ€‹

Routing is the process that routers uses to determine the path that IP packets should take over a network to reach their destination. Routers stores routes to all of their known destinations in a routing table.

There are two main routing methods:

  • Dynamic Routing: Routers uses dynamic rounting protocol(OSPF, BGP, etc.) to exchange routing information with other routers.
  • Static Routing: A Network Administrator manually configures the routing table.

Route Selectionโ€‹

When a router receives a packet, it selects the most specific route to use to send the packet. The most specific route is the route that matches the destination IP address the most.

For example, a packet destined for 192.168.1.1 is matched by both routes as below:

  • 192.168.1.0/24 (192.168.1.0 is the network address and 24 is the subnet mask which means all addresses from 192.168.1.0 to 192.168.1.255 are included)
  • 192.168.1.1/32 (192.168.1.1 is the destination IP address and 32 is the subnet mask which means only the address 192.168.1.1 is included)

The router will select the most specific route to use to send the packet. In this case, the router will select the route with the longest prefix match.

Default Gatewayโ€‹

The default gateway is a route that is used when the router doesn't have a more specific route to use. Router uses the default gateway to send a packet to destination outside of the router's network. A default route is route to 0.0.0.0/00.0.0.0/0 which means all destinations. Default gateway is also known as the gateway of last resort.

Routing Configurationโ€‹

When you configure an IP address on a router interface, a local route is automatically created. For example, if you configure the interface e00/00 with the IP address 192.168.1.1/24192.168.1.1/24, the local route 192.168.1.0/24192.168.1.0/24 will be automatically added to the routing table.

Let's say we have the following network and we want to connect PC11 to PC44.



routing-1.svg


Routing configuration will look like below. We are selecting a route through R22 to reach PC44.

RouterDestinationNext Hop
R1192.168.1.0/24Connected
192.168.4.0/24192.168.12.1
R2192.168.1.0/24192.168.12.1
192.168.4.0/24192.168.24.4
R4192.168.1.0/24192.168.24.2
192.168.4.0/24Connected