如何在 ruby 中 ping ipv6 地址

How to ping ipv6 addresses in ruby

如何 ping ipv6 地址并在 Ruby 中得到响应? Net/ping 仅适用于 ipv4 地址。

require 'net/ping'

Net::Ping::External.new('ipv6.google.com')

在最新版本的 gem 中有一个用于 ipv6 的 ping6 方法,但我无法让它为您的 URL 工作。

https://github.com/chernesk/net-ping/commit/3f2f44b7460628e0d9d49bce2343ffb2fa77cd7d

Added a new ping6 method in both external.rb and ping.rb. This is a close copy of the current 'ping' method logic in both of these classes, the only difference being that it calls the system ping6 command.

This allows the class to be used to ping ipv6 addresses.

irb(main):001:0> require 'net/ping'
=> true
irb(main):002:0> Net::Ping::External.new('ipv6.google.com').ping6
=> false

这可能会给你更多的东西。