From: Zach Dennis Date: 2005-10-27T00:46:12+09:00 Subject: Re: Getting IP addresses 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? Zach