Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a following up question to an question I found answered on (see link below).

What is the difference between the following two routing table entries:

default            E.F.G.H     UGSc            0        0     en1
default            E.F.G.H     UGScI          25        0     en1

(Where E.F.G.H is some gateway IP address.) Specifically what effect does the RTF_IFSCOPE flag have on the routing table entry?

Source: Routing Tables: What is the effect of the RTF_IFSCOPE flag?

The accepted answer then is that the second route is "bound to a specific interface" and this can be used to "create multiple routes that point to the same destination, differentiated only by which interface is in play"

OK, but what does that mean? Let's say I have the following (as I really do, only changed the IPs):

default          UGSc           14        0     en2
default          UGScI           1        0     en0

Under what circumstances will the second route be used? Or more generally when will the "I" route be used? The "real" default route seems to be the one without the "I". Because:

$ route get
    route to:
destination: default
       mask: default
  interface: en2
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500         0 

Btw: I know about the following from man netstat:

I       RTF_IFSCOPE      Route is associated with an interface scope

But I do not understand it :(

Any hints are much appreciated!

share|improve this question

Using the route command's -ifscope option binds a route to a specific interface, which shows in netstat output with the I flag.

The decision on when to use your second route will be by its IP address and metrics, or if requested directly. In case of duplicate IP addresses, the best route is chosen which may not be by the bound interface. A syntax exists for forcing the usage of a given interface, but I don't know exactly which operating systems or utilities support this syntax. This applies usually more to iPv6.

Example on how to specify scope information:

  • When the scope information is an interface name :

    ping fe80::1%eth0

  • When the scope information is an interface index :

    ping fe80::9:47:100:112%65541

The decimal value 65541 is interpreted by the operating system according to its algorithms (not a good idea to use).

share|improve this answer
The decision on when to use your second route will be by its IP address and metrics, or if requested directly. – scherand Jul 1 '12 at 2:01
I think the magic is in this sentence: The decision on when to use your second route will be by its IP address and metrics, or if requested directly. In my little example I have two default routes. Do you mean the second one would be used for something like ping -I <IP of en0> (i.e. interface requested directly)? What is the meaning of "by its IP address and metrics"? – scherand Jul 1 '12 at 2:09
Metric="cost". For an IP, a route is used if : (1) requested by name, or if name not specified, (2) It is the only one for the IP, or in case of duplicates (3) its metric is the lowest, or if metrics are equal, (4) by whatever operating system algorithms. The usual method is to set the metric of the route you don't prefer to higher. See for example this and this. – harrymc Jul 1 '12 at 6:50
OK, I understand (2), (3) and (4). But not (1) really. If we stick to the example of ping -I <IP of en0> would the -I throw me into case (1)? Is -I "requesting by name"? Also from what I see there are no different metrics (or can I just not see them?) for the two default routes; so does (3) not apply? Straight to (4)? Or what command would allow me to see the metrics on OS X (I checked netstat -rn and route)? – scherand Jul 2 '12 at 5:49
I am not on Linux, but from the manual I doubt that ping -I names an interface in the sense of your question, since -I can be "numeric IP address or name of device", thus ignoring the question of duplicate IPs. The only documented syntax I have found is included in my answer, and as I said I don't know to what degree it is implemented. Interface naming seems to be a gray zone only partially treated. Linux system calls can surely accept interface names, but it seems that not all applications fully implement a syntax for them. – harrymc Jul 2 '12 at 7:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .