xcorp::When it rains, it pours.

"The nice thing about rain," said Eeyore, "is that it always stops. Eventually."

IPv4 to IPv6

意外とラクチンなのね。

#!/usr/bin/ruby --
require 'ipaddr'

ipv6Network = IPAddr.new('2001:db8:dead:beef::/64')
ipv4Addr = IPAddr.new('192.168.0.1')
ipv6Addr = (ipv4Addr.ipv4_compat | ipv6Network)
puts("IPv6 Address: #{ipv6Addr.to_string}")

結果。

[xcorp@ipv6 ~]$ ./ipv6.rb
IPv6 Address: 2001:0db8:dead:beef:0000:0000:c0a8:0001
[xcorp@ipv6 ~]$