Mass Hostname-to-IP Address Converter
November 20, 2007 9:26 AM   Subscribe

Is there a program that can find the ip addresses of many network devices on a corporate internal network, and create a neat list automatically?

I manage the main print servers on a major corporate network in the US. I have a long list of the TCP ports being used by these servers to send print jobs to the printers. Because we use DHCP for the printers, these TCP ports are all in the form of the print devices' hostnames. So in effect, I have a list of some 1300 hostnames and I want to make a list of the CURRENT IP addresses of all these hostnames. Is there a program that will automatically ping all these hostname from the list and produce a corresponding list exportable to .csv of all the IP addresses?

I tried googling but was only able to find web-based apps that worked for internet hosts. These are devices on the internal corporate network. I am hoping there's a simple app that can do this.
posted by BigLankyBastard to Computers & Internet (16 answers total) 5 users marked this as a favorite
 
Preferred platform to run the application on? (OS X, Windows, Linux, etc...)
posted by zap rowsdower at 9:33 AM on November 20, 2007


I'm going to assume Windows and throw a couple names out. "Angry IP Scanner" is a nice tiny little app I used back at my old job when I was in undergrad. I'm not sure if it'll export to csv, but from what I recall, it does output the information into rows and columns, so it should be capable of something like that.
posted by omnipotentq at 9:38 AM on November 20, 2007 [1 favorite]


Response by poster: Sorry - I'll be running this off a Windows XP Pro workstation on an Active Directory domain. Or Server 2003.
posted by BigLankyBastard at 9:38 AM on November 20, 2007


NMAP is the canonical answer and it will run on windows, albeit not quite as well as it does on *NIX boxes.
posted by Skorgu at 9:40 AM on November 20, 2007 [1 favorite]


Well... this sounds like a job for Perl to me !

http://nopaste.ch/528e57b05039e22.html

file hostlist.txt in the same directory as the script should have a line separated list of your 1,300 hostnames

it will then create iplist.csv

I don't have the means to try it on Windows at the moment but it should work the same...
http://www.activestate.com/Products/activeperl/
posted by vitrum at 9:51 AM on November 20, 2007


Response by poster: Wow. This question has brought out the hardcore coders and gurus. Have mercy on a lowly infrastructure guy, since I am plainly out of my depth in these discussions.

The Angry IP Scanner looks like it only resolves IP addresses to hostnames, not vice-versa. Also, it triggers the corporate SAV security when downloaded.

NMAP looks extremely powerful, but I am at a loss as to how exactly to phrase the command line syntax to get what I want without making my workstation look like it's a network security threat. I'm afraid I'll trigger a broad scan by accident or something and earn myself a strong slap.

The PERL script may do the trick - it looks simple enough, but I have no idea how to go about making it work on my computer. Is there any way to get that in a ready-to-use format (like .exe) without jacking around with converting it myself? I really appreciate all the suggestions so far.
posted by BigLankyBastard at 10:06 AM on November 20, 2007


Superscan 3 does exactly that. I prefer it to the more recent SS4.
posted by mrbugsentry at 10:14 AM on November 20, 2007


Wait, I didn't read the question right.

SS will get you the list. Since you have a WinXP box, I'd yank it into MS Access and do a join on the host names, then format it into a pretty little report.
posted by mrbugsentry at 10:18 AM on November 20, 2007


Response by poster: MrBugSentry, I'm trying to figure out how to use either version 3 or 4 to get the program to resolve hostnames to IP addresses in bulk. I found a "Bulk Resolve" option that let me import the list of hostnames, but it failed to resolve any but two of them, oddly. What am I doing wrong?

Again, I have a huge list of hostnames in text format (not ip addresses) and I want something that will import the list of hostnames and just pings each hostname or otherwise queries my local/internal DNS and gathers the IP address into a csv or plain text list. I don't need port scan summaries, I don't need UDP, but I DO need something that I can fire and forget until it has compiled the list. I really can't believe nobody has created a simple app that performs this tedious task.
posted by BigLankyBastard at 10:39 AM on November 20, 2007


The DHCP server will know, ask whoever runs that for the list.
posted by zeoslap at 10:42 AM on November 20, 2007


Best answer: perl to exe gets very messy... just tried for kicks and couldn't get it to run...

if the port scanners don't quite do what you need here's a backup plan for ya

download perl

go to start/programs/active perl/perl package manager
at the ppm> prompt type "install Net-DNS"
close window when it's done

copy the script text here into a file named perlscript.pl in a new directory... along with hostlist.txt mentioned above

from a dos prompt run this from that directory
perlscript.pl your-dns-server-ip

changed the script slightly to allow you to specify the internal dns server in case there was any confusion in auto detection
posted by vitrum at 10:46 AM on November 20, 2007


zeoslap has a point too :)
posted by vitrum at 10:47 AM on November 20, 2007


Response by poster: Yeah, I already tried talking to the keepers of the DNS servers, and they seem to think the DNS/MSWINS database for DHCP is not queryable in any helpful manner. Effectively they said they'd have to plug in each hostname manually, just like I would. So that's out.
posted by BigLankyBastard at 10:52 AM on November 20, 2007


Response by poster: Vitrum, Oh MY GOD you did it.

Ladies and Gentlemen, I asked for an application and this GOD wrote it from scratch. Works like a charm, my man! And in like ten seconds, too! I cannot be any happier with the outcome!

I owe you big time for this boon. Next time you're in MN hit me with a MefiMail and I'll buy you several libations of your choice.
posted by BigLankyBastard at 11:18 AM on November 20, 2007


I have some WMI/VBS scripts that can do this.. the one I just cropped together uses WMI on the remote computer to tell you the IP. So if you run it as domain admin the list will populate, if you can't, let me know and I'll make a pinging one...

Create a text file called: hoststoping.txt
fill it with host names:
comp1
comp2
comp3

Save the following code as "pingstuff.vbs"

Put them in the same directory..

open a CMD as domain admin.. type:
cscript pingstuff.vbs

you should get a list of host names then IP..

This was a quick and dirty script, so if it doesn't work MefiMail me :)


-----------------------------------

Const ForReading = 1
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("Wscript.Network")
Dim strHost


On Error Resume Next

Set objFile = objFSO.OpenTextFile("hoststoping.txt", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine

strHost = strLine

getIP(strLine)



Loop

objFile.Close




function getIP(strComputer)

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")


Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")

For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
wscript.echo strComputer & VBTAB & IPConfig.IPAddress(i)
Next
End If
Next


end function
posted by mattdini at 11:24 AM on November 20, 2007


this looks like a job for ping, cat, awk, sed, and grep to me.

Download "unix tools for windows" and run from a ccommand line. Shell scripting this, if you have never done it before, should not take more than a day to work out and is fun!
posted by jannw at 1:46 PM on November 21, 2007


« Older Why does it hurt?   |   ISBN to cover photo Newer »
This thread is closed to new comments.