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.
If a router's interface
X is configured with the IP address 18.104.22.168, 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 22.214.171.124/24.
Therefore, the Router will add to its Routing Table that the Network 126.96.36.199/24 maps to Interface X.
Should this same Router now come across a packet destined to the to 188.8.131.52 (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 (184.108.40.206 - .255), the Router will forward the packet out Interface
Let us now imagine an administrator configures the Router for two Static Routes that claim:
- 220.127.116.11/32 exists out Interface
- 18.104.22.168/28 exists out Interface
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...
... 22.214.171.124, this packet matches only one route and will be forwarded out Interface
... 126.96.36.199, this packet matches two routes, and will be forwarded out Interface
... 188.8.131.52, this packet matches all three routes, and will be forwarded out Interface
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 184.108.40.206), 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 220.127.116.11), 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 18.104.22.168 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