Iain Buclaw
05/23/2026, 11:55 PM#!/opt/puppetlabs/puppet/bin/ruby
# frozen_string_literal: true
require 'ipaddr'
class IPIterator < IPAddr
def succ
mask_size = if prefix <= 8
24
elsif prefix <= 16
16
elsif prefix <= 24
8
else
1
end
clone.set(@addr + (2**mask_size), @family)
end
end
IPIterator.new('172.16.0.0/12').to_range.map do |value|
puts "#{value}"
end
The number of iterations has gone from 16 -> 524,288
There's another call to 10.0.0.0/8 too, which would iterate something like 16M times I guess. 😬