Thursday, November 13, 2014

IPv6 Supernetting Subnetting Ruby

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

# /32 CIDR -> /40's (LONG)
(0..255).each { |x|  puts IPAddr.new("1234:5678:#{sprintf("%02x",x)}00::0").to_i }

# /32 CIDR -> /48's (LONG)
(0..255).each { |x|  puts IPAddr.new("1234:5678:00#{sprintf("%02x",x)}::0").to_i }

No comments:

Post a Comment