3. How does the kernel determine the route to use when there are multiple matching rules in the routing table, such as in the scenario where a host needs to send data to an address covered by both the default route and a specific route (e.g., 10.23.2.0/24)?
In this case the kernel prefers the address with longest destination prefix that matches. Both default address i.e. 0.0.0.0/0 and 10.23.2.0/24 also matches hence the latter one is preferred.
In situations where the kernel encounters multiple matching rules in the routing table, for instance, when a host needs to transmit data to an address covered by both the default route (0.0.0.0/0) and a specific route (e.g., 10.23.2.0/24), the kernel prioritizes the route with the longest destination prefix. Here, CIDR notation becomes useful. Both the default address (0.0.0.0/0) and the specific route (10.23.2.0/24) match, but the latter one with a prefix length of 24 bits is preferred. The longer prefix ensures more specificity in the routing decision.