Hi All,
Does anyone know the best way programmatically verify that a given domain name actually exists?
Thanks, Carl.
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 ---
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
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.