设置ruby whois gem的Whois服务地址 [英] Setting address of whois service for ruby whois gem

查看:130
本文介绍了设置ruby whois gem的Whois服务地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Using the ruby whois gem, how do I set the server address of the whois service?

设置bind_host时出现错误.

Setting the bind_host, I get an error.

> 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查找的主机,而是它绑定到0.0.0.0 或本地服务器上的所有适配器.

I'm pretty sure bind_host doesn't refer to the host used for the whois lookup, but instead refers to the adapter binding on the server running your code. By default it binds to 0.0.0.0, or all the adapters on the local server.

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

If you want to have the whois gem use a custom server address for looking up whois information then it appears that you have to specify it in one of the following ways:

# 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")

这些示例摘自 https://www.rubydoc.info/gems/whois/Whois/Server .

这篇关于设置ruby whois gem的Whois服务地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆