Search code examples
javascriptdns

Can I perform a DNS lookup (hostname to IP address) using client-side Javascript?


I would like to use client-side Javascript to perform a DNS lookup (hostname to IP address) as seen from the client's computer. Is that possible?


Solution

  • There's no notion of hosts or ip-addresses in the javascript standard library. So you'll have to access some external service to look up hostnames for you.

    I recommend hosting a cgi-bin which looks up the ip-address of a hostname and access that via javascript.