How does a router use a routing table to determine over which path to send a packet?

If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

All nodes on an IP network maintain routing information in routing tables. These tables contain information of how to reach systems that are attached to both local and remote networks. The routing tables are generated from local configuration information and from routing protocol messages that is exchanged with neighboring systems.

  • When a host system initially sends a packet, it looks up the packet's destination address in its routing table to determine if the destination is on the local network. If yes, the packet goes directly to the host with that IP address. If not, the packet goes to a router on the local network.

  • When a router receives a packet, the router checks its routing table to determine if the destination address is for a system on one of it's attached networks or if the message must be forwarded through another router. It then sends the message to the next system in the path to the destination.

  • This process is repeated on each router that receives the message until the message reaches the destination system.

  • Refer to Chapter 2, Configuring a System as a Router, in Configuring an Oracle Solaris 11.2 System as a Router or a Load Balancer .

    The following figure shows a network topology with three networks that are connected by two routers.

    Figure 1-4  A Network Topology With Three Interconnected Networks

    How does a router use a routing table to determine over which path to send a packet?

    Router R1 connects networks 192.9.200.0/24 and 192.9.201.0/24. Router R2 connects networks 192.9.201.0/24 and 192.9.202.0/24.

      If Host A on network 192.9.200.0/24 sends a message to Host B on network 192.9.202, the following events occur:

    1. Host A examines its routing tables for the path to 192.9.202.10. The local network address range does not cover this address, but there is a previously learned default route through router R1 that covers the address. Therefore, Host A sends the packet to Router R1.

    2. Router R1 examines its routing tables. No local network's address range covers the destination address, but there is a known route to network 192.9.202.0/24 through Router R2 that covers the address, Router R1 sends the packet to Router R2.

    3. Router R2 is connected directly to network 192.9.202.0/24. The routing table lookup reveals that 192.9.202.10 is on the attached network. Router R2 sends the packet directly to Host B.

      A routing table is a set of rules, often viewed in table format, that's used to determine where data packets traveling over an Internet Protocol (IP) network will be directed. This table is usually stored inside the Random Access Memory of forwarding devices, such as routers and network switches.

      In computer networking, each routing table is unique and acts as an address map for networks. It stores the source and destination IP addresses of the routing devices in the form of prefixes along with the default gateway addresses and corresponding routing information.

      Routing tables are typically updated dynamically through network routing protocols. But sometimes network administrators might add static entries manually.

      How does a routing table work?

      The main purpose of a routing table is to help routers make effective routing decisions. Whenever a packet is sent through a router to be forwarded to a host on another network, the router consults the routing table to find the IP address of the destination device and the best path to reach it. The packet is then directed to a neighboring router -- or the next hop listed in the table -- until it reaches its final destination.

      According to AWS, to handle network traffic, a router consults its routing tables millions of times each second.

      Routing table entries

      Each routing table might contain different entries and information, such as IPv4 or IPv6 address classes. But the primary fields of all routing tables stay the same.

      The following are the main entries of a routing table:

      • Destination. This is the IP address of the packet's final destination.
      • Subnet mask. Also known as the netmask, this is a 32-bit network address that identifies whether a host belongs to the local or remote network. To enhance routing efficiency and reduce the size of the broadcast domain, administrators can apply a custom subnet mask through the process of subnetting, which can divide a network into two or smaller connected networks.
      • Gateway. This is the next hop, or the neighboring device's IP address to which the packet is forwarded.
      • Interface. Routers typically use Ethernet interfaces to connect to other devices on the same network, such as eth0 or eth1, and serial interfaces to connect to outside wide area networks (WANs). The routing table lists the inbound network interface, also known as the outgoing interface, that the device should use when forwarding the packet to the next hop.
      • Metric. This entry assigns a value to each available route to a specific network. The value ensures that the router can choose the most effective path. In some cases, the metric is the number of routers that a data packet must cross before it gets to the destination address. If multiple routes exist to the same destination network, the path with the lowest metric is given precedence.
      • Routes. This includes directly attached subnets, indirect subnets that aren't attached to the device but can be accessed through one or more hops, and default routes to use for certain types of traffic or when information is lacking.
      How does a router use a routing table to determine over which path to send a packet?
      Screenshot of the contents of a routing table.

      How does network routing work?

      A network packet must take various steps to reach its destination. To understand the relationship between routing and the routing table, examine the following steps that occur during the transfer of data packets:

      1. A computer sends a packet to a router. Similar to the address on a postal package, a sending device -- such as a computer -- attaches IP addresses to data packets and sends them to a router. This helps the router determine the best routes to transport the packets to their destinations. A computer typically connects to a local area network (LAN) to send packets while a router can send packets between different LANs and WANs.
      2. The router receives the packet. Once the router receives the packet, it analyzes it against its internal routing tables to determine the most efficient path to send the packet through. The goal of the router is to forward the packet to the router closest to its ultimate destination.
      3. The router routes the packets. It's unlikely that the initial router will get the packet directly to its destination. It looks at the routing table to get the packet to the next hop. The routing table keeps the hop count low by providing the router with the most effective route. The final hop count is the number of times a packet goes from one router to another until it reaches its destination.
      4. The process is repeated. At the next hop, another router takes over and repeats the same process of determining where to send the packet by looking at its internal routing tables. This process repeats several times before the packet reaches its destination. The routing process might sound lengthy, but it's extremely quick due to the routing protocols involved.
      5. The packet reaches its destination. Once a packet has finally reached a router that resides on the same network as the destination IP address, it's directly routed to the device or server that it was intended for.

      Types of routing: static routing vs. dynamic routing

      Routing is the process of selecting the most ideal path to a network and routers use the information entered in a routing table to determine the best route. Essentially, there are two methods of building and maintaining a routing table: static routing and dynamic routing.

      How does a router use a routing table to determine over which path to send a packet?
      The differences between static and dynamic routing.

      The pros and cons of static routing

      • A network admin manually creates, manages and updates static routing table entries.
      • The entries for static network devices don't change unless a network admin manually changes them.
      • Static routes provide a granular level of control over routing, as each route is manually configured for full connectivity.
      • For large networks, it can become practically impossible to add a manual entry for every route.
      • Static routing saves bandwidth and overhead because routers don't share static routes.
      • Static routing isn't fault tolerant. Any changes to the network infrastructure, such as the addition of a new network or a link going down, aren't automatically updated and require manual intervention.
      • In a static environment, if a link becomes unavailable, the routers don't have the option to automatically switch to a better route.
      • Static routes always have an administrative distance (AD) of 1, which is given preference over dynamic routes, unless the AD is changed. A modified AD is known as a floating static route.

      The pros and cons of dynamic routing

      • In dynamic routing, devices automatically build and maintain their routing tables by using routing protocols to exchange information about the surrounding network topology. Examples of routing protocols include Routing Information Protocol, Enhanced Interior Gateway Routing Protocol and Open Shortest Path First.
      • Dynamic routing tables let devices listen to the network and respond to occurrences such as device failures and network congestion.
      • Dynamic routing consumes more bandwidth and overhead because routers share the dynamic routes with each other.
      • A router can dynamically choose a better path if there's a change in the routing infrastructure.
      • Dynamic routing is easier and simpler to configure on larger networks.
      • Dynamic routing lets routers load balance between multiple links.
      • The routing protocols -- not the network admin -- choose the best routes to the destination.

      Subnetting plays a vital role in the world of IP routing. Learn how to break a network into smaller subnets and calculate the subnet mask of an IP address based on the required number of subnets and hosts.

      How a router determines the path to send its packets?

      When a router receives a packet, the router checks its routing table to determine if the destination address is for a system on one of it's attached networks or if the message must be forwarded through another router. It then sends the message to the next system in the path to the destination.

      How does a router determine which destination to use in a routing table?

      A computer sends a packet to a router. Similar to the address on a postal package, a sending device -- such as a computer -- attaches IP addresses to data packets and sends them to a router. This helps the router determine the best routes to transport the packets to their destinations.

      How does a router handle a packet when it can t identify a known path in the routing table?

      If the table does not contain the destination address, the router forwards the packet to another router that is listed in its routing table. Refer to Configuring an IPv4 Router for detailed information on routers. The following figure shows a network topology with three networks that are connected by two routers.

      How does a router determine which destination to use in a routing table quizlet?

      When a packet arrives at the router interface, the router examines the packet header to determine the destination network. If the destination network MATCHES a route in the routing table, the router FORWARDS the packet using the information specified in the routing table.