Zach Dennis wrote:
> Zach Dennis wrote:
> 
>> Mark Van Holstyn wrote:
>>
>>> Does anyone know how to get an ip address from within ruby? I would 
>>> like to
>>> be able to grab both the ip of computer( the one assigned by my local
>>> network ) and the ip to the outside world. Any help would be great.
>>
>>
>>
>>
>> irb -r socket
>> irb> Socket.getaddrinfo( Socket.gethostname, Socket::AF_INET )
>> => [["AF_INET", 2, "lima", "10.0.1.44", 2, 2, 17]]
> 
> 
> This answered your first question about your local system. The above 
> works on window, but on unix systems this will return whatever is setup 
> in your /etc/hosts file for your hostname. If you want to resolve IP by 
> dns, then look into using the Resolv library from the standard library...
> 
> To your second question. What is your ip to the outside world? Are you 
> referring to the ip address on your router? Or do you have multiple ip 
> addresses assigned to your local system?
> 
I guess he's behind a NAT firewall and wants to know the IP address on 
the provider side.
The way I used to resolve this was by using a service like 
www.whatismyip.com or www.showmyip.com any one of the dynamic dns services.
Closest thing to a webservice I found is http://www.ippages.com/xml/ 
although the RSS format (http://www.ippages.com/rss.php) might be easier 
to parse.
If anyone knows of a nice and free web service for this, let us know.
Cheers,
V.-
-- 
http://www.braveworld.net/riva

____________________________________________________________________
http://www.freemail.gr - δωρεάν υπηρεσία ηλεκτρονικού ταχυδρομείου.
http://www.freemail.gr - free email service for the Greek-speaking.