Web Connection
How to see if a domain exists
Gravatar is a globally recognized avatar based on your email address. How to see if a domain exists
  Carl Chambers
  All
  Oct 24, 2017 @ 05:56pm

Hi All,

Does anyone know the best way programmatically verify that a given domain name actually exists?

Thanks, Carl.

Gravatar is a globally recognized avatar based on your email address. re: How to see if a domain exists
  Rick Strahl
  Carl Chambers
  Oct 24, 2017 @ 09:55pm

There's no real foolproof way to do this but you can get pretty close by doing a reverse domain lookup using GetIpFromDomain().

If you get an IP address back the domain should be valid. Tne catch is that it only works with top level domains (ie. west-wind.com, not support.west-wind.com - The IP resolver will return the root domain IP in each case).

But there's literrally a catch though - most ISP's use a catch all IP address to redirect you to a search page if a DNS lookup fails. You can still deal with this by capturing that domain.

Something like this should get you started:

DO wwAPI
? IsValidDomain("west-wind.com")
? IsValidDomain("bogusDomainForRealz.com")
? IsValidDomain("weblog.west-wind.com")
? IsValidDomain("Funkywest-wind.com")

RETURN

FUNCTION IsValidDomain(lcDomainName)

PUBLIC _gcKnownBogusIp
IF VARTYPE(_gcKnownBogusIp) # "C"
   _gcKnownBogusIp = GetIpFromDomain("TotallyBogusAndInvalidDomainName.com")
ENDIF

lcIP = GetIpFromDomain(lcDomainName)
RETURN lcIP # _gcKnownBogusIP

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: How to see if a domain exists
  Carl Chambers
  Rick Strahl
  Oct 25, 2017 @ 07:26am

But there's literrally a catch though - most ISP's use a catch all IP address to redirect you to a search page if a DNS lookup fails.

That's the part that was hanging me up. Thanks for the work-around, I appreciate it.

Carl

Gravatar is a globally recognized avatar based on your email address. re: How to see if a domain exists
  Harvey Mushman
  Rick Strahl
  Oct 26, 2017 @ 04:39pm

I forget all of the DNS stuff but as I recall NSLOOKUP will get you even closer. After you specify the TLD, I think you can gt the authoritative record and then list all of the sub domains as records.

I think the only thing that you can't see is a valid email address. That requires sending a request for a specific address to the email server and seeing what comes back. But the MX record should be exposed from NSLOOKUP.

© 1996-2024