为 ruby whois gem 设置 whois 服务地址
Setting address of whois service for ruby whois gem
使用rubywhoisgem,如何设置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
我很确定 bind_host
不是指用于 whois 查询的主机,而是指 refers to the adapter binding on the server running your code. By default it binds to 0.0.0.0 或本地服务器上的所有适配器。
如果您想让 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")
使用rubywhoisgem,如何设置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
我很确定 bind_host
不是指用于 whois 查询的主机,而是指 refers to the adapter binding on the server running your code. By default it binds to 0.0.0.0 或本地服务器上的所有适配器。
如果您想让 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")