Re: Determine My IP Address (was Re: How to get client IP address assigned by Cisco VPN client)
Re: Determine My IP Address (was Re: How to get client IP address assigned by Cisco VPN client)
- Subject: Re: Determine My IP Address (was Re: How to get client IP address assigned by Cisco VPN client)
- From: "Justin C. Walker" <email@hidden>
- Date: Sun, 23 Apr 2006 18:00:57 -0700
On Apr 23, 2006, at 17:20 , Duane Murphy wrote:
--- At Sun, 23 Apr 2006 15:50:40 -0700, Justin C. Walker wrote:
On Apr 23, 2006, at 13:06 , Duane Murphy wrote:
[snip]
What is the best way for me to get the IP address that the other end
would use? Would a routing socket be the best way? But doesn't that
require root/authenticated access? Is there another, simpler way?
Your system has a bunch of IP addresses, so you are going to have to
tell your clients which address to use. For example, here in my home
network, my main system has several IPv6 addresses and several IPv4
addresses. The v4 addresses include: globally routable IP address
(assigned by my IP), and one private IP address for each of several
interfaces. In fact, the interface to the outside world has several
IP addresses itself, for some fiddling I am doing locally. That is
why the system won't be able to guess which IP address your code
really wants to listen on.
Hope that makes sense.
Yes, all of that makes sense. I'm still wondering what the best
solution
would be to determine which address to tell to the other client.
That is a Question For The Ages. The answer involves the details of
the configuration of your system, its network environment, and IP
routing.
The one that makes the most sense to me, if it works the way that I
think it does, is the routing socket. If I could ask the routing logic
which local ip address would be used for some destination address, I
think that would be great.
At the risk of being pedantic :-}
first, there are domain names, IP addresses, and routes. Part of the
answer depends on how your clients access your service. Normally,
it's done by domain name (fiddlesticks.mac.com, for example), rather
than IP address. Your service runs on a system with at least one
host name, so your client will typically contact you via that name.
There is some complexity introduced by the interaction between
firewalls, NAT, and the domain name system, which I will ignore.
The best, for your customers/clients, is that the domain name for the
server/service is well-known, so they can just enter the name; then
the system(s) can handle the rest.
If you must use IP addresses, then it's going to be somewhat less
than automatic. Each system comes with at least two interfaces (a
built-in ethernet device; loop-back; dialout/modem; ...), and each of
those will typically sport at least one IP address when enabled.
Figuring out how to define what it means to be "the IP address" for
your system is not straight-forward.
There is no good "100%" solution, because of the complexity
involved. The 90% solution may be to figure out the primary active
interface (using SystemConfiguration), and assume that the "best"
address is the first one on the list of associated addresses. If
there is more than one address, though, the answer will not be well-
defined, so you have to have a faith-based approach :-}
That may be more than you wanted to know, and doesn't really give you
an answer to your question. I hope it clarifies things enough so
that you can figure out what to do next :-}
Cheers,
Justin
--
Justin C. Walker, Curmudgeon-At-Large
Institute for the Absorption of Federal Funds
--------
If you're not confused,
You're not paying attention
--------
_______________________________________________
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