rubyruby-on-rails-4whois-ruby

whois-rb gem produces error: "Whois::ServerNotFound"


I'm totally lost here. I was trying to set up the whois gem according to the documentation at https://whoisrb.org/. Unfortunately I'm always getting an error when trying to perform a whois, locally on my machine.

Error message:

Unable to find a WHOIS server for `;; answer received from 192.168.178.1 (75 bytes) ;; ;; security level : unchecked ;; ->>header<<- opcode: query, status: noerror, id: 51102 ;; flags: qr rd ra cd; query: 1, answer: 1, authority: 0, additional: 1 opt pseudo-record : payloadsize 512, xrcode 0, version 0, flags 32768 ;; question section (1 record) ;; google-public-dns-b.google.com. in a ;; answer section (1 record) google-public-dns-b.google.com. 84453 in a 8.8.4.4 '

Don't get confused, I'm using the dnsruby gem as well.. The corresponding code in my model:

def set_isp res = Resolver.new a_record = res.query(self.domain_name) whois = Whois::Client.new rec = whois.lookup(a_record) self.isp = rec.name end

Thanks a lot in advance!


Solution

  • According to the error, the issue is that you are passing the result of

    a_record = res.query(self.domain_name)
    

    straight to

    whois.lookup
    

    but the content of the a_record is not a domain name. Instead, it's a full DNS response:

    ;; answer received from 192.168.178.1 (75 bytes) 
    ;;
    ;; security level : unchecked
    ;; ->>header<<- opcode: query, status: noerror, id: 51102
    ...
    

    Please make sure the input is a valid domain name (or IP address).