1

A Connection to whois.arin.net is not open to us. Our network administrators say we should use 192.0.47.59 for our whois service.

In some cases I will have a DNS name, in other cases I will have an IP address. I want to get the whois information in either case. My network administrators have allowed access to a specific IP address for the whois service, and I have to use that IP address. The define method allows me to set the IP address of the whois service if I give it the TLD, but I have no way to get it work for IP addresses.

This is related to Setting address of whois service for ruby whois gem, but since I got a partial solution, I know how to call the service, so for my question specific to IP addresses I thought I would start over.

I need to set the address of our whois service. So for a DNS name:

> Whois.whois('wandajackson.com')
Whois::ConnectionError: Errno::EHOSTUNREACH: No route to host - connect(2) for "whois.verisign-grs.com" port 43
    from (irb):4
> Whois::Server.define(:tld, 'com', '192.0.47.59')
=> ["com", "192.0.47.59", {}]
irb(main):006:0> Whois.whois('wandajackson.com')
# => #<Whois::Record>

However, I cannot get it to work for IP addresses.

> Whois::Server.define(:ipv4, '74.0.0.0/8', '192.0.47.59')
=> ["74.0.0.0/8", "192.0.47.59", {}]
> Whois.whois('74.220.215.203')
Whois::ConnectionError: Errno::EHOSTUNREACH: No route to host - connect(2) for "whois.arin.net" port 43
    from (irb):7

> Whois::Server.define(:ipv6, '2607::/8', '192.0.47.59')
=> ["2607::/8", "192.0.47.59", {}]
> Whois.whois('2607:f8b0:4004:800::200e')
Whois::ConnectionError: Errno::EHOSTUNREACH: No route to host - connect(2) for "whois.arin.net" port 43
    from (irb):9
Marlin Pierce
  • 9,931
  • 4
  • 30
  • 52
  • I think you got it mixed up. It you setup a record for whois you are matching the domain `wandajackson.com` (:tld com) to an IP address. You ask with an IP address you get record from whois; you ask with a domain name you get the record from whois. Why are you trying to do a pair with IP/IP? – tukan Sep 22 '18 at 18:40
  • In some cases I will have a DNS name, in other cases I will have an IP address. I want to get the whois information in either case. My network administrators have allowed access to a specific IP address for the whois service, and I have to use that IP address. The define method allows me to set the IP address of the whois service if I give it the TLD, but I have no way to get it work for IP addresses. – Marlin Pierce Sep 23 '18 at 13:06
  • I see that makes sense. I got curious and tested your code for the ip4 and it worked correctly (got a reply). Could you test your connection for `whois.arin.net` on port `43` via e.g. telnet? Why is your first query asking `whois.verisign-grs.com` and the second whois.arin.net? (I got -Whois::Server.define(:ipv4, '74.0.0.0/8', '192.0.47.59') => ["74.0.0.0/8", "192.0.47.59", {}] 2.5.1 :003 > Whois.whois('74.220.215.203') => "\n#\n# ARIN WHOIS data and services are ... – tukan Sep 23 '18 at 17:00
  • Connection to `whois.arin.net` is not open to us. Our network administrators say we should use `192.0.47.59` for our whois service. – Marlin Pierce Sep 23 '18 at 22:15
  • I see. Now I understand your problem! I'll check it out. – tukan Sep 24 '18 at 09:37
  • I more detail - I would recommend using name `whois.iana.org` instead of 192.0.47.95. The chances that IANA changes IP address is rather small, but it increases readability & also should IANA change address it will still work (when IT changes the firewall rules). – tukan Sep 24 '18 at 18:48

1 Answers1

1

I'm sorry to say but that is a bug with missing 74.0.0.0/8 assigment & if you create your own it is probably not correctly searched for in the defined list thus => The assigment according to IP does not currently work.

Why?

You can check the list and find out which ranges are assigned to ARIN:

Whois::Server.definitions(:ipv4).each { |records| p "IP range #{records[0]}" if records[1] = 'whois.arin.net'}

First without any changes you check your IP address:

 Whois::Server.find_for_ip("74.220.215.203")
=> #<Whois::Server::Adapters::Arin:0x00000000030244c0 @type=:ipv4, @allocation="0.0.0.0/1", @host="whois.arin.net", @options={}>

As you can see the record is not found at the authorities so it goes to a fallback 0.0.0.0/1 which is set for whois.arin.net.

I tried to set fatory (gets somehow ignored) and define:

Whois::Server.factory :ipv4, "74.0.0.0/8", "whois.iana.org", :option => Whois::Server::Adapters::Standard

define worked:

Whois::Server.define :ipv4, "74.0.0.0/8", "whois.iana.org"

... , {}], ["222.120.0.0/15", "whois.nic.or.kr", {}], ["222.122.0.0/16", "whois.nic.or.kr", {}], ["222.232.0.0/13", "whois.nic.or.kr", {}], ["220.0.0.0/6", "whois.apnic.net", {}], ["74.0.0.0/8", "whois.iana.org", {}]]

As you can see there is assigment of

["74.0.0.0/8",
> "whois.iana.org", {}]]

so you should be able to query IANA now? It appears you are not:

Whois::Server.find_for_ip("74.220.215.203")
=> #<Whois::Server::Adapters::Arin:0x000000000434c250 @type=:ipv4, @allocation="0.0.0.0/1", @host="whois.arin.net", @options={}>

As you can see the @allocation is still getting "0.0.0.0/1" and not 74.0.0.0/8. Why? That I don't know yet. Probably some bug either on searching or finding the correct Object.

Everything is lost? Not really, there is rather simple workaround but you have to understand the implications.

Workaround

If you define your fallback address via:

Whois::Server.define :ipv4, "0.0.0.0/1", "whois.iana.org"

Everything starts to work. Now all the fallback queries will be done via IANA, which should not be a problem in your case as you can't reach ARIN anyways.

Now if you query via IP adddress you get correct results:

Whois::Server.find_for_ip("74.220.215.203")
=> #<Whois::Server::Adapters::Standard:0x000000000351c298 @type=:ipv4, @allocation="0.0.0.0/1", @host="whois.iana.org", @options={}>

Whois.whois("74.220.215.203")
=> "% IANA WHOIS server\n% for more information on IANA, visit http://www.iana.org\n% This query returned 1 object\n\nrefer:        whois.arin.net\n\ninetnum:
    74.0.0.0 - 74.255.255.255\norganisation: ARIN\nstatus:       ALLOCATED\n\nwhois:        whois.arin.net\n\nchanged:      2005-06\nsource:       IANA\n\n"
tukan
  • 17,050
  • 1
  • 20
  • 48