Jeff Abrahamson on Wed, 27 Aug 2003 09:31:15 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] finding the IP


On Wed, Aug 27, 2003 at 07:42:21AM -0400, Walt Mankowski wrote:
>   [29 lines, 175 words, 1154 characters]  Top characters: oetsnair
> 
> On Tue, Aug 26, 2003 at 08:49:26AM -0400, eric@lucii.org wrote:
> > Anyone know how to reliably determine the IP address of a box that's
> > using PPPOE?
> 
> From perlfaq9:
> 
>   How do I find out my hostname/domainname/IP address?
> 
>   The normal way to find your own hostname is to call the `hostname` pro-
>   gram.  While sometimes expedient, this has some problems, such as not
>   knowing whether you've got the canonical name or not.  It's one of
>   those tradeoffs of convenience versus portability.
> 
>   The Sys::Hostname module (part of the standard perl distribution) will
>   give you the hostname after which you can find out the IP address
>   (assuming you have working DNS) with a gethostbyname() call.
> 
>       use Socket;
>       use Sys::Hostname;
>       my $host = hostname();
>       my $addr = inet_ntoa(scalar gethostbyname($host || 'localhost'));
> 
>   Probably the simplest way to learn your DNS domain name is to grok it
>   out of /etc/resolv.conf, at least under Unix.  Of course, this assumes
>   several things about your resolv.conf configuration, including that it
>   exists.
> 
>   (We still need a good DNS domain name-learning method for non-Unix sys-
>   tems.)

All of these things assume that the ip you see is what the rest of the
world sees. My ip as I write this is 192.168.0.6. You will see the
address of my gateway, puddle.purple.com = 216.158.45.183.

I believe the only reliable way to know your ip from the outside,
barring knowledge of the network between you and there, is to check
from the outside. Thus the httpd solutions.

-- 
 Jeff

 Jeff Abrahamson  <http://www.purple.com/jeff/>
 GPG fingerprint: 1A1A BA95 D082 A558 A276  63C6 16BF 8C4C 0D1D AE4B

Attachment: pgpWSyLkXzHut.pgp
Description: PGP signature