LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Reverse DNS lookup from a file (https://www.linuxquestions.org/questions/linux-newbie-8/reverse-dns-lookup-from-a-file-759700/)

mlapl1 10-04-2009 07:15 PM

Reverse DNS lookup from a file
 
Hello I have a file consisting of unique IP addresses - one per line

I want to find the name of the host for each address.

I tried the following:

Quote:

nslookup < file_name


This worked except it gives me a lot of extraneous information such as the servers providing the answers. This is too much information for me and would simply like each line of IP numbers to be replaced with a domain name.

I tried using the same strategy using host and hostname and dig but I must have given the wrong command as I had no results.

I would appreciate advice.

Thanks
Andrew

Tinkster 10-04-2009 07:59 PM

for i in `cat file_name `; do host $i; done|awk '{print $5}'

AlucardZero 10-04-2009 08:02 PM

Code:

dig +short -f filename
Filename contains:
Code:

-x 1.2.3.4
-x 5.6.7.8

etc.

Tinkster 10-04-2009 08:46 PM

nifty :}


All times are GMT -5. The time now is 01:25 PM.