What is a routing table and how does longest prefix match work?
IntermediateConceptIP Addressing, CIDR, Subnetting & Routing
Answer
A routing table maps destination prefixes to a next hop or interface. The router picks the most specific matching route: a /24 beats a /16 beats 0.0.0.0/0. Ties are broken by administrative distance or metric.
ip route show
ip route get 10.0.2.15 # shows which route and source IP would be used
In AWS the same rule applies in VPC route tables: the more specific route wins, and a local route for the VPC CIDR always exists and cannot be overridden by a less specific route.
More on IP Addressing, CIDR, Subnetting & Routing
What is an IPv4 address and how is it structured?BeginnerWhat are the private IPv4 ranges (RFC 1918)?BeginnerWhat is CIDR notation?BeginnerHow many usable hosts are in a /24, and why minus two?BeginnerSubnet 10.0.0.0/16 into /24 subnets. How many do you get and what are the first three?IntermediateGiven 172.16.37.200/21, what is the network address, broadcast and range?Intermediate