Solved

Is there a tool anywhere that can perform an nslookup and resolve an IP to a domain name using a list of IP Addresses?

Posted on 2004-10-28
875 Views
Last Modified: 2008-03-04
I have a list of IP addresses (websites users are surfing too). We want to know the domains that these IPs resolve too, however, performing an nslookup or whois on each and every single IP would be insane!

Is there a tool anywhere that can perform an nslookup and resolve an IP to a domain name using a list of IP Addresses?

Thanks
0
Question by:stzin
    8 Comments
     
    LVL 95

    Accepted Solution

    by:
    Just script it.  Assuming it's a pure list of IPs, like:

    192.168.1.55
    10.44.55.12
    192.168.77.41

    Then the script/command (under NT-XP) would look something like this:

    for /f "tokens=1" %a in (ipaddresses.log) do @ nslookup %a >> lookups.log

    0
     
    LVL 95

    Expert Comment

    by:Lee W, MVP
    (If you made that a command in a script, then you'd need to add a % to the %a's - they would look like %%a)

    You can then further parse the lookups.log file by using FIND and dumping that output to a file.  What information do you want?  just the domain name/system name?  If so then you would do something like this in a file.cmd:

    for /f "tokens=1" %a in (ipaddresses.log) do @nslookup %a >> lookups.log
    find /i "Name:" lookups.log > names.log

    0
     
    LVL 6

    Expert Comment

    by:joopv
    nmap can do this.

    http://www.insecure.org/nmap/
    0
     
    LVL 1

    Author Comment

    by:stzin
    leew where you wrtite "Name:" what should I actually be putting in there?
    0
     
    LVL 1

    Author Comment

    by:stzin
    When I run the for script I keep getting "a was unexpected at this time".

    I've tried different itterations of the script, like,
    for /F "tokens=1" %a IN (ips.txt) DO nslookup %a

    where ips.txt is a list with only 4 ips that looks like this:

    100.100.100.100
    101.101.10.1.101
    102.1.1.1
    103.1.1.1


    Im trying to keep it as simple as possible just so I cant get some sort of output..what am I doing wrong?

    0
     
    LVL 6

    Expert Comment

    by:joopv
    Did you try nmap yet?  It does exactly what you need.
    0
     
    LVL 95

    Expert Comment

    by:Lee W, MVP
    If you run FOR /F... as a command, then you use %a.  If you run FOR /F as  a command in a batch file, then it must be referred to as %%a.  I screwed that up, my apologies.
    0
     
    LVL 95

    Expert Comment

    by:Lee W, MVP
    Where I write "Name:" you should be putting "Name:" - I didn't mean for this to be interpreted as a variable.  

    What's going on is that when you run NSLOOKUP WWW.GOOGLE.COM, the output looks something like this:
    Server:  myserver.mydomain.com
    Address:  192.168.0.1

    Non-authoritative answer:
    Name:    www.google.akadns.net
    Addresses:  64.233.161.99, 64.233.161.104
    Aliases:  www.google.com

    So I'm using Find "Name:" - which is in the 5th line of the output and contains the looked up domain.  Find would display that line, but I'm redirecting output from it to a file instead.  If you wanted to get rid of the Name: part of each line in the output file, then you could run this added line in the script (remember %a or %aa depending on whether it's a batch file or just run as a single command on the command line:

    FOR /f "tokens=2" %a in (names.log) DO Echo %a >> namesonly.txt
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

     Java Android Coding Bundle

    Whether you're an Apple user or Android addict, learning to code for the Android platform is an extremely valuable, in-demand skill. It all starts with Java, the language behind the apps and games that make Android the top platform it is today.

    I will assume you are running a non-server version of some sort of Windows throughout this article. There are many flavors of Windows since Windows Server 2000 - 2008, XP Home & Pro, Vista Home & Pro, and Windows 7 Starter, Home, Pro, Ultimate, etc.…
    This is an article about my experiences with remote access to my clients (so that I may serve them) and eventually to my home office system via Radmin Remote Control. I have been using remote access for over 10 years and have been improving my metho…
    Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
    After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

    909 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now