Re: Is there a clean way to get my default IP address.
Re: Is there a clean way to get my default IP address.
- Subject: Re: Is there a clean way to get my default IP address.
- From: "Peter Sichel" <email@hidden>
- Date: Tue, 6 Dec 2005 10:01:42 -0500
On 12/6/05, Justin C. Walker wrote:
>The best you can hope for is to determine the default interface
>(using the SystemConfiguration framework), and select, more or less
>at random, one address on that interface.
This is good advice, but it may also depend on what you want the IP
address for. If you want to hand out the public IP address your machine
can be reached at to someone else and your machine is behind a NAT box,
you can use something like this:
curl -s http://checkip.dyndns.org
If you want to determine the local IP address used for a given
connection to a remote server or host, you can request the local
protocol address from the corresponding socket.
Enjoy!
- Peter
_______________________________________________
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