nslookup: am I doing it right?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting nslookup: am I doing it right?
# 1  
Old 01-05-2011
nslookup: am I doing it right?

Hi guys,

I'm back to get some help again Smilie

I have a file that has a list of IP addresses, and I use nslookup in my script to resolve hostnames of those IPs.

the problem I'm facing is that I not all the hostnames got resolved! and I don't know why. sometimes the same duplicate IP returns a hostname once and nothing the other.
like:
Quote:
1.2.3.4 number.com
1.2.3.4
what could be the problem?

thanks in advance
# 2  
Old 01-05-2011
Afaik. "nslookup" does not search arbitary files.
What did you type?
This User Gave Thanks to methyl For This Post:
# 3  
Old 01-05-2011
the following:

Quote:
nslookup $a | grep -i "name =" | awk '{print $4}'
where the IP address is obtaind from a variable in a loop,

Last edited by Abdulelah; 01-05-2011 at 02:01 PM..
# 4  
Old 01-05-2011
I think what u are looking for is this :
Code:
# dig -x 67.195.160.76 +short 
ir1.fp.vip.ac4.yahoo.com.

Code:
dig -x 67.195.160.76

; <<>> DiG 9.7.0-P1 <<>> -x 67.195.160.76
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54543
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;76.160.195.67.in-addr.arpa.    IN      PTR

;; ANSWER SECTION:
76.160.195.67.in-addr.arpa. 1200 IN     PTR     ir1.fp.vip.ac4.yahoo.com.

;; Query time: 64 msec
;; SERVER: 10.237.129.4#53(10.237.129.4)
;; WHEN: Wed Jan  5 21:07:07 2011
;; MSG SIZE  rcvd: 82

This User Gave Thanks to mtomar For This Post:
# 5  
Old 01-05-2011
What does this do:
Code:
nslookup < file

Without a loop

Last edited by Scrutinizer; 01-05-2011 at 02:29 PM..
This User Gave Thanks to Scrutinizer For This Post:
# 6  
Old 01-05-2011
In my version of "nslookup", the "Name" line contains a colon character not an equals sign. i.e. "Name:" not "Name =".
Please post sample unfiltered output from your "nslookup".


We haven't seen your "loop".
The "nslookup" command would normally only have one parameter in this context. If you give it the lines from your file verbatim in some cases it will be giving "nslookup" two parameters ... with the second parameter interpreted as the name of the nameserver (depending on whether the sample in post #1 is input or output).

There are a lot more complex answers if your nameserver is faulty or if there are multiple nameservers.

Last edited by methyl; 01-05-2011 at 02:45 PM..
This User Gave Thanks to methyl For This Post:
# 7  
Old 01-05-2011
here is the output of my nslookup version:

Quote:
Server: 212.121.0.5
Address: 212.121.0.5#53

Non-authoritative answer:
76.160.195.67.in-addr.arpa name = ir1.fp.vip.ac4.yahoo.com.

Authoritative answers can be found from:
160.195.67.in-addr.arpa nameserver = ns5.yahoo.com.
160.195.67.in-addr.arpa nameserver = ns1.yahoo.com.
160.195.67.in-addr.arpa nameserver = ns2.yahoo.com.
160.195.67.in-addr.arpa nameserver = ns4.yahoo.com.
160.195.67.in-addr.arpa nameserver = ns3.yahoo.com.
ns1.yahoo.com internet address = 68.180.131.16
ns2.yahoo.com internet address = 68.142.255.16
ns3.yahoo.com internet address = 121.101.152.99
ns4.yahoo.com internet address = 68.142.196.63
ns5.yahoo.com internet address = 119.160.247.124
---------- Post updated at 06:53 PM ---------- Previous update was at 06:51 PM ----------

Quote:
Originally Posted by mtomar
I think what u are looking for is this :
Code:
# dig -x 67.195.160.76 +short 
ir1.fp.vip.ac4.yahoo.com.

Code:
dig -x 67.195.160.76

; <<>> DiG 9.7.0-P1 <<>> -x 67.195.160.76
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54543
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;76.160.195.67.in-addr.arpa.    IN      PTR

;; ANSWER SECTION:
76.160.195.67.in-addr.arpa. 1200 IN     PTR     ir1.fp.vip.ac4.yahoo.com.

;; Query time: 64 msec
;; SERVER: 10.237.129.4#53(10.237.129.4)
;; WHEN: Wed Jan  5 21:07:07 2011
;; MSG SIZE  rcvd: 82

thanks for that, but it doesn't work all the time.. just like nslookup
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk nslookup

Hi, I have a rather simple awk statement to perform an nslookup on a file (list of IPs). If the lookup yields a result, then it sends it to a file. If no result, there is no output. I've been trying to use !NR or !NF with an if statement to make the output state "NA" if there is no result,... (5 Replies)
Discussion started by: umang2382
5 Replies

2. Shell Programming and Scripting

nslookup hanging

Hey folks. Long time lurker, first time poster. I'm a bit of a newbie at "coding" (obviously, scripting is a teensy bit different than coding) and I've run into a problem that I just can't seem to get around. I'm going through a list of servers to check their name, IP, reverse-NSLOOKUP name and... (2 Replies)
Discussion started by: Bearwhale
2 Replies

3. Solaris

nslookup command

hi, I am new in Solaris 10 , i am installing a software in solaris 10, while performing pre requisite nslookup command should return without error, and the IP address and host should match those listed in the etc/hosts file, but nslookup command show the below error , can anybody tell me how i... (4 Replies)
Discussion started by: zeeshan047
4 Replies

4. Emergency UNIX and Linux Support

Nslookup!!! Please look up!!!

Hi all Nslookup command returns!!!! Code: nslookup 10.91.44.29 Server: 127.0.0.1 Address: 127.0.0.1#53 29.44.91.in-addr.arpa name = station1.example.com Code: nslookup station1.example.com Server: 127.0.0.1 Address: 127.0.0.1#53 Name: ... (4 Replies)
Discussion started by: anishkumarv
4 Replies

5. Solaris

Further nslookup options if any !!

Hi , I have a requirement to find the aliases by doing an nslookup on the Cname. If i do an nslookup on the alias name i get the Cname , but i need the cname from alias name. eg: Hostname = acb.example.com Virtual name= abcvirtual.example.com nslookup abcvirtual.example.com will... (3 Replies)
Discussion started by: mpics66
3 Replies

6. Shell Programming and Scripting

nslookup output

Hi All, If I give the hostname followed by nslookup, I get the output like below, commandprompt>nslookup efgh Using /etc/hosts on: xyz looking up FILES Trying DNS Non-authoritative answer: Name: abcd Address: 47.47.47.47 Aliases: efgh I am not sure on the bolded ones. Can... (4 Replies)
Discussion started by: Rajakct84
4 Replies

7. UNIX for Advanced & Expert Users

nslookup for Unix

I am connecting from windows via Putty to some other Unix server. How can I display my current windows MachineName/NTID in putty? Thanks :) (4 Replies)
Discussion started by: som.nitk
4 Replies

8. IP Networking

nslookup command?

Hai guys, In which way does the command,"nslookup", will be helpful? Please give me examples. Thanks. (5 Replies)
Discussion started by: Felicia23
5 Replies

9. Shell Programming and Scripting

NSLOOKUP script

Hi Anyone know of a quick and simple way to script an NSLOOKUP's from a list/text file? Thanks, Gav (1 Reply)
Discussion started by: gavcollins
1 Replies

10. UNIX for Advanced & Expert Users

named and nslookup

Guys , Am using Linux - Red Hat 6.1 . My DNS and nslookup command was working fine and ppl. can resolve through this server . but i changed something in /etc/named.conf , that stopped the DNS . The named proccess is working , but nslookup command is not , i get this error message : ... (3 Replies)
Discussion started by: tamemi
3 Replies
Login or Register to Ask a Question