Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h
Created June 14, 2015 18:54
Show Gist options
  • Save gr33n7007h/903cb84de086e068ac09 to your computer and use it in GitHub Desktop.
Save gr33n7007h/903cb84de086e068ac09 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'socket'
def random_hostnames
loop do
begin
octets = Array.new(4) { rand(255) }
hostname = Socket.gethostbyaddr(octets.pack('C4')).first
puts "IP: #{octets.join('.')} -> Hostname: #{hostname}"
rescue SocketError
next
end
end
end
random_hostnames
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment