LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-04-2009, 08:15 PM   #1
mlapl1
LQ Newbie
 
Registered: Jun 2007
Posts: 16

Rep: Reputation: 0
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
 
Old 10-04-2009, 08:59 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
for i in `cat file_name `; do host $i; done|awk '{print $5}'
 
Old 10-04-2009, 09:02 PM   #3
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,808

Rep: Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604
Code:
dig +short -f filename
Filename contains:
Code:
-x 1.2.3.4
-x 5.6.7.8
etc.
 
Old 10-04-2009, 09:46 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
nifty :}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
reverse (batch) dns lookup aptget Programming 3 09-29-2009 04:00 PM
Reverse dns lookup in C virtualCoder Programming 3 09-27-2009 03:24 AM
reverse DNS lookup mimithebrain Linux - Networking 5 06-08-2006 09:28 AM
Reverse DNS lookup, or any way to contact an IP.. MasterC Linux - Networking 6 02-21-2003 04:34 AM
reverse DNS lookup phil1076 Linux - General 1 01-22-2002 04:24 PM


All times are GMT -5. The time now is 11:02 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration