3

I have three questions about the relationship between IP addresses, subnet masks, and forwarding tables:

  1. If the address 125.95.39.129 is in a router's forwarding table (and maps to interface x), does it imply that only packets whose destination is exactly 125.95.39.129 will be forwarded on x? Or, will we have to use the technique in this post to find the subnet to which this host belongs, and then any packet whose destination belongs to that subnet will be forwarded on x?

  2. Let's say that there is another address, 125.95.39.60 in the router's forwarding table, but it is in the forwarding table twice, and both times, it has a different subnet mask (let's call them y and z) associated with it. Accordingly, each entry also maps to a different interface. What does it mean if the same IP address is mapped to two different subnet masks in the forwarding table?

  3. What if the forwarding table also has 125.95.39.0 and is associated with mask m and interface i?

My thinking is that, in the case of #1, we do an exact match between an incoming packet's destination address and that forwarding table entry and only forward on interface x if they're exactly the same.

Assuming that my answer to #1 is correct, for #3, would we forward a packet on i only if the packet's destination is not 125.95.39.60, which is more specific than 125.95.39.0?

3

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:

  1. Most Specific Route
  2. Best (lowest) Administrative Distance
  3. 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

| improve this answer | |
  • 1
    Your route, 125.95.39.60/28, for interface z isn't possible. Masking 125.95.39.60 with /28 gives 125.95.39.48/28. – Ron Maupin Apr 13 '16 at 18:49
  • @RonMaupin woops, subnetting fail, good catch. Fixing now... – Eddie Apr 13 '16 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.