Skip to content

Instantly share code, notes, and snippets.

@kevinzhow kevinzhow/ip_cook.rb
Created Mar 20, 2014

Embed
What would you like to do?
路由转换
#utf-8
require 'netaddr'
newfile = File.open("some_file", "w")
File.foreach('out_ip').with_index { |line, line_num|
line = line.split(',')[0].to_s
a = NetAddr::CIDR.create(line)
puts "#{a.ip}/#{a.wildcard_mask}"
newfile.write("route = #{a.ip}/#{a.wildcard_mask}\n")
}
newfile.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.