1

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!

CottonEyeJoe
  • 720
  • 1
  • 7
  • 28

2 Answers2

2

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).

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
0

I am not sure where did you go wrong I just try to create a sample apple using the gem whoisrb all I had to do is Add the whois gem to the Gemfile.

#Gemfile
gem 'whois', '~> 3.0'

Now you can open the console and type in

$ client = Whois::Client.new
$ response = client.lookup("google.com")

I created a example git project that will show you how its put together in the controller. I could and should it to a model method

https://github.com/mzaragoza/sample-whoisrb

MZaragoza
  • 10,108
  • 9
  • 71
  • 116