Re: how to tell a socket to use a specific interface...
Re: how to tell a socket to use a specific interface...
- Subject: Re: how to tell a socket to use a specific interface...
- From: Philip George <email@hidden>
- Date: Fri, 20 May 2005 17:11:03 -0500
On May 20, 2005, at 4:51 PM, Josh Graessley wrote:
SO_DONTROUTE probably isn't nearly as useful as you might imagine.
SO_DONTROUTE means don't go through a router. The stack will look for
a network directly accessible on one of the interfaces. This requires
an address in that network assigned to an interface. When SO_DONTROUTE
is set, the packet won't be sent through a gateway and the stack won't
check the routing table determine if there are additional locally
accessible networks. Since the destination you were trying to reach is
not local to either interface, both attempts fail.
Mac OS X's routing is based only on the destination address. When you
don't set the SO_DONTROUTE option, the packet is sent based on the
destination address. Even though you bound to an address on en0, if
the route says go out interface en1 to get to the destination, that is
where the stack will send the packet. Sometimes this just works. Other
times, this gets tripped when ingress filtering is enabled and a
router drops the packet because it has the wrong source address or the
source address is a private address that needed to be translated by a
NAT.
Josh -
Thanks. That's all very helpful. I wondered why SO_DONTROUTE was
causing no connections to get thru. I'm looking at the Darwin source
for traceroute, which has code in it for binding to a specific local
interface, but when I try traceroute at the commandline, I get strange
results (not so strange I guess, considering what you just wrote about
OS X's routing being based on only the destination address):
DEAD INTERFACE : en0 192.168.1.106
GOOD INTERFACE : en1 192.168.1.154
when i do: traceroute -s 192.168.1.154 www.whatever.com
... i get:
1 * * *
2 * * *
....
changing it to the bad interface: traceroute -s 106 www.whatever.com
... should just give up after it can't get past the first hop, but i
STILL get:
1 * * *
2 * * *
....
and, lastly, the man page states clearly that specifying an address
that isn't available, will cause traceroute to not send any packets at
all. it should just die with an error, but i STILL get:
1 * * *
2 * * *
....
I'm amazed that this can't be circumvented. It's presumably extra work
for the network layer to have to figure out the best route anyway. One
would think that the easiest possible solution for sending packets is
to hard-code the interface like I'm trying to do. I don't get why that
wouldn't be an option. And I'm surprised traceroute's man page doesn't
reflect this behavior in OS X.
In any case, thanks.
If you think of any other ways around my problem, please let me know.
- Philip
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden