Skip to content

Instantly share code, notes, and snippets.

@smarj
Created May 7, 2012 14:57
Show Gist options
  • Save smarj/2628220 to your computer and use it in GitHub Desktop.
Save smarj/2628220 to your computer and use it in GitHub Desktop.
Naive reverse resolver
#!/usr/bin/env ruby -wKU
require 'resolv'
while line = gets
ip = line.chomp
begin
host_name = Resolv.getname(ip)
rescue Resolv::ResolvError => error
host_name = "noname"
end
puts ip + ", " + host_name
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment