LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-23-2011, 03:13 AM   #1
bennetthaselton
LQ Newbie
 
Registered: Dec 2010
Posts: 12

Rep: Reputation: 0
how to make nslookup return failure if DNS server fails


I'm trying to find a command to tell nslookup, "I want you to try to resolve hostname X using DNS server Y, and if the lookup fails, just output failure -- do NOT fail over to some other DNS server as a backup and use it to try to resolve the same hostname."

I'm trying to follow the man page instructions for doing this, but it doesn't seem to work. The man page for nslookup on my system (CentOS 5.5) includes the line:

"[no]fail Try the next nameserver if a nameserver responds with SERVFAIL or
a referral (nofail) or terminate query (fail) on such a response."

But if I try using that option, the output seems to indicate that after the lookup failed on ns1.afraid.org, nslookup failed over to 208.67.220.220 (the first nameserver listed in my resolv.conf -- an OpenDNS nameserver) and used it to resolve the hostname instead:

>>>
peacefire:/var/www/html# nslookup -fail www.snakemaker.com ns1.afraid.org
Server: 208.67.220.220
Address: 208.67.220.220#53

Non-authoritative answer:
www.snakemaker.com canonical name = snakemaker.com.
Name: snakemaker.com
Address: 66.36.247.191
>>>

That's not what I want. I want the command to return failure if ns1.afraid.org doesn't resolve the hostname. (Mainly so I can glance at output quickly and see whether a lookup failed on a specific server -- without getting confused by extra lines which report "success", when it actually failed on the server that I care about.) How do I specify that?

(The nameserver ns1.afraid.org seems to switch back and forth between resolving and not resolving that hostname, so the above command might not give the same result if you try it.)

(By the way, the man page for nslookup on my system doesn't inspire a lot of confidence -- e.g. at the beginning it says:
"For example, to change the default query type to host information, and the initial timeout to 10
seconds, type:

[new section] INTERACTIVE COMMANDS"

... In other words, someone forgot to fill in the example command after the word "type:" I tried a few different CentOS 5.5 systems and they all had the same sentence missing.)
 
Old 03-23-2011, 08:18 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,001

Rep: Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629
http://linux.die.net/man/1/nslookup

See how to use options for the server you wish to view.

See also dig.

Your version of nslookup may or may not be similar too. We'd need to know that.
 
Old 03-23-2011, 08:32 PM   #3
bennetthaselton
LQ Newbie
 
Registered: Dec 2010
Posts: 12

Original Poster
Rep: Reputation: 0
As I said in my original message, I read the man page for nslookup, but the instructions in the man page don't seem to work:

nslookup -fail www.snakemaker.com ns1.afraid.org

does not behave as expected, and instead fails over to my local DNS server if ns1.afraid.org is not working. I don't want it to fail over.

On another forum where I offered cash for the correct answer, someone suggested to use dig instead:

dig www.snakemaker.com @ns1.afraid.org

and that does seem to behave the way I want (if encountering failure, it doesn't try any other server).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot nslookup the DNS server from client pc ! shipon_97 Linux - Newbie 2 04-22-2009 05:49 AM
DNS server: prob in nslookup command visitashu Red Hat 1 04-12-2006 11:34 AM
nslookup: no response, captured 3 "server failure" packets trainpic Linux - Networking 3 02-08-2006 10:14 AM
dns client fails after power failure (Debian Sarge) faked Linux - Networking 6 01-25-2005 01:05 PM
NSlookup with DNS server piglingz Linux - Networking 1 04-08-2003 09:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration