Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Domain name existence via "dig"

Tags:

dns

dig

whois

Would it be possible to check a domain name its existence by checking the output of "dig"? Inside the bind sources I found these constants:

0 DNS_R_NOEROR
1 DNS_R_FORMERR
2 DNS_R_SERVFAIL
3 DNS_R_NXDOMAIN
4 DNS_R_NOTIMP
5 DNS_R_REFUSED
6 DNS_R_YXDOMAIN
7 DNS_R_YXRRSET
8 DNS_R_NXRRSET
9 DNS_R_NOTAUTH
10 DNS_R_NOTZONE
16 DNS_R_BADVERS

<RCODE 11>     # 11 has no macro
<RCODE 12>     # 12 has no macro
<RCODE 13>     # 13 has no macro
<RCODE 14>     # 14 has no macro
<RCODE 15>     # 15 has no macro

In my opinion NOERROR & SERVFAIL means the hostname exists (although it doesn't mean an ip is linked to it). NXDOMAIN would mean it absolutely not exists.

I prefer not to use whois because it is quite slow. dig is much faster as I just need to be certain that the hostname doesn't exist yet.

Could someone shine their light on my assumptions and the other macros?

Thanks

like image 697
Salvania Avatar asked Jan 16 '11 07:01

Salvania


1 Answers

Well, in some cases it might work, but in most cases you will see incorrect results- some domains are registered but do not have a record in the TLD name server. And some domains have a record configured but are not registered as some registries have wildcard domains configured:

$ dig asdfasdfasdfxvyxv123.de.com A +short 
91.213.214.122

$ whois -h whois.centralnic.com asdfasdfasdfxvyxv123.de.com
DOMAIN NOT FOUND

whois indeed is slow - speak to a/your domain provider, most registries offer faster methods to check if a domain is registered or not (i.e. EPP protocol)

like image 101
Oliver Peter Avatar answered Oct 11 '22 17:10

Oliver Peter