Skip to content

Instantly share code, notes, and snippets.

@oogali
Created June 2, 2013 05:38
Show Gist options
  • Select an option

  • Save oogali/5692728 to your computer and use it in GitHub Desktop.

Select an option

Save oogali/5692728 to your computer and use it in GitHub Desktop.
One-line DNS resolution of IPs
# ipv4 only
def gethostbyaddr(ip)
Socket.gethostbyaddr(ip.split('.').map(&:to_i).pack('CCCC')).first rescue ip
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment