building on the link provided by Stressless-IT here is a batch file that takes in a list of IP address and exports the results to a file
Main Topics
Browse All TopicsI'm trying to get hostnames from IP addresses. Is there a DOS command that would take a list (input file), do an NS lookup and output the results (IP addres, Hostname) to a file?
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Try this I just posted in another q:
http://www.experts-exchang
@echo on
(
for /f %%p in (iplist.txt) do (
for /f "tokens=2 delims=[]" %%a in ('ping -n 1 -w 100 %%p^|find "Pinging"') do echo %%p,%%a
)
) > output.txt
Ahh that is because you have used an IP address. When you do a PING of a host name then it resolves the address to an IP and puts it in [] e.g.
ping www.google.co.uk
but when you ping an IP it doesn't.
I imagine that is what it is.
The echo on should be echo off too, sorry.
e.g. with iplist.txt containing
www.google.com
I get:
www.google.com,208.69.34.2
in the output.txt file. You can make it open in Excel uif you want with:
@echo off
(
for /f %%p in (iplist.txt) do (
for /f "tokens=2 delims=[]" %%a in ('ping -n 1 -w 100 %%p^|find "Pinging"') do echo %%p,%%a
)
) > output.csv
start output.csv
Sorry my mistake but I mis-read you wanting IP from hostname, try this for the opposite:
@echo off
(
for /f %%p in (iplist.txt) do (
for /f "tokens=2 delims=[] " %%a in ('ping -a -n 1 -w 100 %%p^|find "Pinging"') do echo %%p,%%a
)
) > output.txt
notepad output.txt
Still uses ping -a to get the name but it could instead use nslookup and parse the output if needed.
Steve
The solution works good for about 1/3 of my entries. Come to find out, there are only a couple of DHCP servers on our network with the entire database, so I need to set one of them as a default. I know how to do this within NSlookup, but am unfamiliar with how to do it within a batch or commandline.
So close!!
Business Accounts
Answer for Membership
by: stressless-ITPosted on 2009-11-03 at 07:56:11ID: 25730187
http://support.microsoft.c om/kb/2005 25
here is what you need