How forwarding decisions are made
A forwarding decision is a network routing process that
-
determines the appropriate interface for packet transmission based on destination address matching in the routing table
-
prioritizes routes with longer network prefix lengths when multiple matches exist, and
-
directs packets through default routes when no specific routing table entries match the destination.
Forwarding decision process
Forwarding decisions are made as follows:
-
If the destination does not match an entry in the routing table, the packet is forwarded through the interface specified for the default route. If a default route has not been configured, the packet is discarded.
-
If the destination matches a single entry in the routing table, the packet is forwarded through the interface associated with that route.
-
If the destination matches more than one entry in the routing table, then the packet is forwarded out of the interface associated with the route that has the longer network prefix length.
Note | Existing connections continue to use their established interfaces even if a new similar connection would result in different behavior due to a change in routes. |
Longest prefix match example
For example, a packet destined for 192.168.32.1 arrives on an interface with these routes in the routing table:
-
192.168.32.0/24 gateway 10.1.1.2
-
192.168.32.0/19 gateway 10.1.1.3
In this case, a packet destined to 192.168.32.1 is directed toward 10.1.1.2, because 192.168.32.1 falls within the 192.168.32.0/24 network. It also falls within the other route in the routing table, but 192.168.32.0/24 has the longest prefix within the routing table (24 bits verses 19 bits). Longer prefixes are always preferred over shorter ones when forwarding a packet.