How do you convert an IPv6 address into a binary representation and back?
I was only able to convert it to a number, then attempting to convert that to a string.
IPAddr.new('fe80::c')
# => #<IPAddr: IPv6:fe80:0000:0000:0000:0000:0000:0000:000c/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>
IPAddr.new('fe80::c').to_i
# => 338288524927261089654018896841347694604
As @tadman pointed out, dealing with it as a number doesn’t make sense. Converting it to binary is ideal.
Convert from IPv6 to bytes:
Convert from bytes to IPv6: