Forums
New posts
New posts
Search forums
Market
Domains/Websites Wanted
.com Domain Market
gTLD Domain Market
ccTLD Domain Market
Web3 Domain Market
Third-Level Domain Market
Adult Domain Market
What's New
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Account Upgrade
Premium Members Directory
Log in
Register
What's New
calendar
Search
Search
Search titles only
By:
New posts
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.
Forums
Domain Discussion
Domain Beginners and Newbies
Best Domain Availability Checking Apis?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="katherine" data-source="post: 2217191" data-attributes="member: 63835"><p>For non-existent domains you'll get an NXDOMAIN response like this:</p><p>[CODE]; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> -t ns p.com</p><p>;; global options: +cmd</p><p>;; Got answer:</p><p>;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 26644</p><p>;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0</p><p>[/CODE]</p><p>But dig will not return an error in this case.</p><p></p><p>So I think you should look at both response and error code.</p><p>Error codes are as follows:</p><p></p><p>[CODE]0: Everything went well, including things like NXDOMAIN</p><p>1: Usage error</p><p>8: Couldn't open batch file</p><p>9: No reply from server</p><p>10: Internal error[/CODE]</p><p>Source: <a href="http://linux.die.net/man/1/dig" target="_blank">http://linux.die.net/man/1/dig</a></p><p></p><p>So if you do dig -t ns +short <some non-existent domain>, you'll a return code of 0 (=OK) but no NS.</p><p>For scripting I would stick to dig -t ns +short, because it's easier to interpret the results programmatically.</p><p></p><p>To sum up there are 3 possible outcomes:</p><ol> <li data-xf-list-type="ol">return code !=0 => an error occured</li> <li data-xf-list-type="ol">return code =0, NS returned => domain is taken</li> <li data-xf-list-type="ol">return code =0, no NS returned => domain does not exist, or has no name server, or is in redemption etc.</li> </ol><p>You only have to double-check domains that fall under 1. or 3.</p><p></p><p>If you do something like:</p><p>[CODE]dig -t ns +short .com; echo $?[/CODE]</p><p>You'll get:</p><p>[CODE]dig: '.com' is not a legal name (unexpected end of input)</p><p>10[/CODE]</p><p></p><p>You can suppress the error messages like this:</p><p>[CODE]dig -t ns +short .com > /dev/null 2>&1; echo $?[/CODE]</p><p>Result:</p><p>[CODE]10[/CODE]</p><p></p><p>A quick script would be along these lines:</p><p>[CODE]#!/bin/bash</p><p></p><p>export LC_ALL=C</p><p></p><p>echo -n "Domain to check: "</p><p>read domain</p><p>echo "Domain: $domain"</p><p></p><p>ns=$(dig -t ns +short "$domain" 2> /dev/null)</p><p>err=$?</p><p>if [ "$err" -ne 0 ]; then</p><p> echo "An error occured (code: $err)"</p><p>else</p><p> # response empty ?</p><p> if [ ! -z "$ns" ]; then</p><p> echo -n "NS found: "</p><p> echo "$ns" | tr "\n" " "</p><p> else</p><p> echo "No NS found"</p><p> fi</p><p>fi</p><p>[/CODE]</p><p>It should handle the three possible situations and you could output the results to a CSV file.</p><p>Again, this is quick & dirty code for demonstration purposes.</p></blockquote><p></p>
[QUOTE="katherine, post: 2217191, member: 63835"] For non-existent domains you'll get an NXDOMAIN response like this: [CODE]; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> -t ns p.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 26644 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0 [/CODE] But dig will not return an error in this case. So I think you should look at both response and error code. Error codes are as follows: [CODE]0: Everything went well, including things like NXDOMAIN 1: Usage error 8: Couldn't open batch file 9: No reply from server 10: Internal error[/CODE] Source: [url]http://linux.die.net/man/1/dig[/url] So if you do dig -t ns +short <some non-existent domain>, you'll a return code of 0 (=OK) but no NS. For scripting I would stick to dig -t ns +short, because it's easier to interpret the results programmatically. To sum up there are 3 possible outcomes: [LIST=1] [*]return code !=0 => an error occured [*]return code =0, NS returned => domain is taken [*]return code =0, no NS returned => domain does not exist, or has no name server, or is in redemption etc. [/LIST] You only have to double-check domains that fall under 1. or 3. If you do something like: [CODE]dig -t ns +short .com; echo $?[/CODE] You'll get: [CODE]dig: '.com' is not a legal name (unexpected end of input) 10[/CODE] You can suppress the error messages like this: [CODE]dig -t ns +short .com > /dev/null 2>&1; echo $?[/CODE] Result: [CODE]10[/CODE] A quick script would be along these lines: [CODE]#!/bin/bash export LC_ALL=C echo -n "Domain to check: " read domain echo "Domain: $domain" ns=$(dig -t ns +short "$domain" 2> /dev/null) err=$? if [ "$err" -ne 0 ]; then echo "An error occured (code: $err)" else # response empty ? if [ ! -z "$ns" ]; then echo -n "NS found: " echo "$ns" | tr "\n" " " else echo "No NS found" fi fi [/CODE] It should handle the three possible situations and you could output the results to a CSV file. Again, this is quick & dirty code for demonstration purposes. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Domain Discussion
Domain Beginners and Newbies
Best Domain Availability Checking Apis?
Top
Bottom