tomkr4l
tomkr4l

Reputation: 322

How to ping ipv6 addresses in ruby

How is possible to ping ipv6 address and get respond in Ruby? Net/ping works just with ipv4 addresses.

require 'net/ping'

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

Upvotes: 1

Views: 432

Answers (1)

kcdragon
kcdragon

Reputation: 1733

There is a ping6 method in the latest version of the gem that is for ipv6 but I could not get it to work for your URL.

See 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

This might give you more to go on.

Upvotes: 1

Related Questions