Skip to content

Instantly share code, notes, and snippets.

@dgalarza
Created September 14, 2009 20:42
Show Gist options
  • Save dgalarza/186915 to your computer and use it in GitHub Desktop.
Save dgalarza/186915 to your computer and use it in GitHub Desktop.
Simulate creating 10 random IP numbers, converted to Hexadecimal string
# Uses built in ruby functions to handle conversions etc
# Create 10 IPs
for ips in 1...10
ip = ""
#generate a random segment for each IP part (4 parts for each IP)
for segment in 1...4
ip += rand(255).to_s(16).upcase
end
puts ip
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment