views:

43

answers:

1

I have a app that needs to connect over a socket to a remote computer that now has multiple IP addresses. Is there a way to turn the remote Hostname or IP a list of all the IPs that the system has?

Possibly (Hostname | Ip) => (RemoteMAC) => IPs?

These will be windows server 2003/2008 machines.

A: 
require 'resolv-replace'
Resolv::DNS.new.each_address("oreilly.com") { |addr| puts addr }

produces:

208.201.239.101
208.201.239.100

http://codeidol.com/other/rubyckbk/Internet-Services/Performing-DNS-Queries/

Jay
I cant get your example to work but it looks the same as Socket::getaddrinfo('www.google.com', 'www', nil, Socket::SOCK_STREAM).each do |a, p, n, ip| puts addr end Which work for Google but not locally. I believe this is because of the DNS which has multiple IPs registered with the name. The servers I'm working with only have one IP registered with their name in DNS
JustSmith
The only way to get IP addresses from a name is by looking up the IPs somewhere. The IPs of the machines your trying to access must be published somewhere for you to look them up. There is no way to magically discover them. If this information is not available, there is no way your program can get it.
Jay