设置ruby whois gem的Whois服务地址

时间:2018-09-20 18:24:20

标签: ruby rubygems whois whois-ruby

使用ruby whois gem,如何设置whois服务的服务器地址?

设置bind_host时出现错误。

> whois_client = Whois::Client.new(bind_host: "192.0.47.59", bind_port: 43)
=> #<Whois::Client:0x00000008188e7e50 @timeout=10, @settings={:bind_host=>"192.0.47.59", :bind_port=>43}>
> record = whois_client.lookup('wandajackson.com')
Whois::ConnectionError: Errno::EADDRNOTAVAIL: Can't assign requested address - bind(2) for "192.0.47.59" port 43
    from (irb):4

1 个答案:

答案 0 :(得分:1)

我很确定bind_host不是指用于whois查找的主机,而是http://docs.grafana.org/installation/configuration/。默认情况下,refers to the adapter binding on the server running your code或本地服务器上的所有适配器。

如果要让whois gem使用自定义服务器地址来查找whois信息,那么看来您必须通过以下方式之一进行指定:

# Define a server for the .com TLD
Whois::Server.define :tld, "com", "your.whois.server.address"
Whois.whois("google.com")

# Define a new server for an range of IPv4 addresses
Whois::Server.define :ipv4, "10.0.0.0/8", "your.whois.server.address"
Whois.whois("10.0.0.1")

# Define a new server for an range of IPv6 addresses
Whois::Server.define :ipv6, "2001:2000::/19", "your.whois.server.address"
Whois.whois("2001:2000:85a3:0000:0000:8a2e:0370:7334")

这些示例摘自it binds to 0.0.0.0