You're asking a good questions. And to answer them properly we have to explore Routers and how they function.
Router's populate Routing Tables (which you are calling a Forwarding Table, the terms are synonymous). A Routing Table contains many mappings of either a network to an interface or a network to a next-hop IP.
There are multiple ways a Router can learn entries for its Routing Table. The two which are relevant to your questions are Directly Connected Routes or Static Routes.
- A Directly Connected route is a mapping learned due to an interface's configuration.
- A Static Route is a mapping learned by an administrator manually telling the Router about the location of a particular network.
For example:
If a router's interface X
is configured with the IP address 125.95.39.129, with a mask of 255.255.255.0, the Router can use the technique in this post to determine that the Network (or Subnet) this IP address resides in is 125.95.39.0/24.
Therefore, the Router will add to its Routing Table that the Network 125.95.39.0/24 maps to Interface X.
Should this same Router now come across a packet destined to the to 125.95.39.129 (the Router's own interface X IP address), the Router will forward the packet to its CPU for processing.
Should this same Router now come across a packet destined to any other IP address in the network (125.95.39.0 - .255), the Router will forward the packet out Interface X
.
Let us now imagine an administrator configures the Router for two Static Routes that claim:
- 125.95.39.68/32 exists out Interface
Y
- 125.95.39.64/28 exists out Interface
Z
Both of these networks contain IP addresses in the same network as the one connected to Interface X
. So in essence, you have three overlapping routes. It is common, and perfectly acceptable, for a Routing Table to have entries that overlap.
In this case, should the router receives a packet destined to...
... 125.95.39.55, this packet matches only one route and will be forwarded out Interface X
... 125.95.39.65, this packet matches two routes, and will be forwarded out Interface Z
... 125.95.39.68, this packet matches all three routes, and will be forwarded out Interface Y
What governs this behavior is the rules of Overlapping routes. In all cases, what determines which route will be selected follows these rules:
- Most Specific Route
- Best (lowest) Administrative Distance
- Best (lowest) Route Metric
In the second case above (packet destined to 125.95.39.65), the /28 static route is more specific than the /24 directly connected route, so /28 is chosen.
In the third case above (packet destined to 125.95.39.68), the /32 static route is more specific than the /28 static, and /24 directly connected, so the /32 gets chosen.
Should there be two routes with the same specificity (aka, two /32 routes, or two /24 routes, etc), Administrative Distance would break the tie. Administrative Distance is an arbitrary number set to 'rate' and set difference preferences for different sources of learning routes.
For instance, Static Routes typically have a Administrative Distance of 1, and Directly Connected routes have an Administrative Distance of 0. Which means should a /24 Static Route exist as well as /24 Directly Connected route, the Directly Connected route would be preferred.
Metric is a final tie breaker, it is an arbitrary value associated with each Route to specify how preferred that particular route is compared to other routes learned from the same mechanism and for with the same specificity.
Summary / TLDR
The answers to your questions are in the explanation above. But to summarize...
.#1 -- it depends how 125.95.39.129 is in the Router's forwarding table. AKA, as a /32 route? As a /24 route?
.#2 -- Most specific route will always take precedence
.#3 -- Most specific route will always take precedence, followed by Administrative Distance