• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how to tell a socket to use a specific interface...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 19:18:07 -0500


On May 20, 2005, at 6:29 PM, Justin Walker wrote:

Without seeing netmasks, it's hard to tell, but note that IP routing rules require that you *not* have addresses in the same subnet on two different interfaces. What netmask are you using? If it's something like 255.255.255.0 (or anything ending in .0), I think that is (part of) your problem.


you're right. i hadn't thought of that. changing one of the routers' gateway address to 192.168.0.250 helped a little.

so now it looks like:

GATEWAY of GOOD ROUTER :  192.168.1.1
ADDRESS of WIFI IFACE  :  192.168.1.104

GATEWAY of DEAD ROUTER :  192.168.0.250
ADDRESS of CAT5 IFACE  :  192.168.0.101


..with netmasks of 255.255.255.0 on both
(here, "DEAD" means: the LAN side works fine, but the WAN side has no connection to the internet.)



the symptoms are still the same for pretty much everything i've described, but since i last wrote, i've been playing around with the 'route' commandline tool (only for display info, not changing anything). before changing the lan-side address on the "DEAD" router, it was constantly opting to choose en1 (WIFI) to route packets that were impossible to reach via en0 (CAT5).


for instance, before the change (assume the only difference is that DEAD ROUTER = 192.168.1.1 and CAT5 IFACE = 192.168.1.105):

route get -host 192.168.1.1 192.168.1.106
...would choose en1 (WIFI) even though 192.168.1.106 is ONLY reachable by the CAT5 line.


after changing the networks so that there could be no confusion, this problem vanished.


but still, the following code still gets autorouted, even after the call to bind():


// setup local address stuff...

struct sockaddr_in LOCaddr;
LOCaddr.sin_family = AF_INET;
LOCaddr.sin_addr.s_addr = inet_addr(local_ip);


// bind to specific interface...

if (bind(sockethandle, (struct sockaddr *)&LOCaddr, sizeof(LOCaddr))==0) {
// send()...
// recv()...
// ...
}



i want it to bind to the bad route and then fail, as opposed to picking the next best thing and proceeding as if nothing were wrong with the selected route. also, in the situation where i had two good routes to two separate networks, i'd still need to send certain requests thru one network and certain requests thru the other.


the end goal is to be able to get the user's public ip address for ANY and ALL active network connections that can reach the internet. A cgi is called on my web server that spits back the caller's address, which will of course be the public address. none of this works without being able to distinguish between the different interfaces when sending the request for the cgi.

right now, it looks like en1 AND en0 both have the same public address. there should, of course, be only the public address for en1 and **nothing** for en0, since it can't even get to the internet.

hooking the DEAD router to the internet (so that each separate route can make its way to to the cgi and back), again, yields duplicate public ip addresses, even though they should be different.

any ideas?

- 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


  • Follow-Ups:
    • Re: how to tell a socket to use a specific interface...
      • From: Justin Walker <email@hidden>
References: 
 >how to tell a socket to use a specific interface... (From: Philip George <email@hidden>)
 >Re: how to tell a socket to use a specific interface... (From: "Peter Lovell" <email@hidden>)
 >Re: how to tell a socket to use a specific interface... (From: Philip George <email@hidden>)
 >Re: how to tell a socket to use a specific interface... (From: Josh Graessley <email@hidden>)
 >Re: how to tell a socket to use a specific interface... (From: Philip George <email@hidden>)
 >Re: how to tell a socket to use a specific interface... (From: Justin Walker <email@hidden>)

  • Prev by Date: Re: how to tell a socket to use a specific interface...
  • Next by Date: Re: how to tell a socket to use a specific interface...
  • Previous by thread: Re: how to tell a socket to use a specific interface...
  • Next by thread: Re: how to tell a socket to use a specific interface...
  • Index(es):
    • Date
    • Thread