Skip to content

Instantly share code, notes, and snippets.

@fluxrad
Created July 18, 2014 19:30
Show Gist options
  • Save fluxrad/89bfd8a114c09b32dfde to your computer and use it in GitHub Desktop.
Save fluxrad/89bfd8a114c09b32dfde to your computer and use it in GitHub Desktop.
Explode a list of netmasks
#!/usr/bin/env ruby
require 'netaddr'
File.open("networks.txt").each_line do |line|
line.chomp!
puts "### #{line} ###"
NetAddr::CIDR.create(line).enumerate.each do |ip|
puts "#{ip}"
end
end
source 'https://rubygems.org'
gem 'netaddr'
10.0.0.0/23
192.168.0.4/16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment