Search code examples
rubysocketsipwindows-server

How to get a list of IPs for a remote computer in Ruby


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.


Solution

  • 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/