Quickest and easiest way to figure out IP names.
October 25, 2010 12:33 PM   Subscribe

I have a list of IP addresses and I need to know the name of the computer they are currently hosted on. What's the best and quickest way for me to get this information?

By this I mean if I use nslookup, what interests me is the name part of that printout. If this were just 5 or so IP addresses, I would be fine, but there a lot, over 400 and I don't want to do them all by hand. Any and all advice would be appreciated. I'm not attached to any specific method so long as I can run it under windows xp.
posted by Carillon to Technology (9 answers total) 1 user marked this as a favorite
 
Is this from your own LAN? You'd probably be better off just getting this from your DHCP server.
posted by JaredSeth at 12:40 PM on October 25, 2010


Response by poster: No that's part of the issue. I can't really get the information from a central source.
posted by Carillon at 12:42 PM on October 25, 2010


Are you trying to say you want to resolve an IP address to its associated name in DNS? Or is it some sort of "internal identifier" that is not in DNS?
posted by Geckwoistmeinauto at 12:48 PM on October 25, 2010


Best answer: Depends on if you're the programmer/cli user type or not. Unixy systems have a program 'ip2hostname' available (it's a Perl script, few if any dependencies, google it). With that you can just :

ip2hostname < one_file > out_file
# or
some_prog | ip2hostname | some_other_prog

and it does a bang up job of finding any dotted-quad type IP address and turning it into a hostname.

I use it pretty much every single day for something or another.
posted by zengargoyle at 12:50 PM on October 25, 2010


Response by poster: Geckwoistmeinauto, I'm not caring if it resolves or not, but the info that is provided with the nslookup command is exactly what I want. I am guessing what I am looking for is the hostname.

zengargoyle, that looks like pretty much what I want. Is there a way I can get that to run on the xp system I am using?
posted by Carillon at 12:54 PM on October 25, 2010


Pretty much only if somebody comes back with a Windows batch file version or some other native Windows solution.

The simple Perl code underneath 'ip2hostname' is just:

echo 174.132.172.58 | perl -MSocket -lne 'print scalar(gethostbyaddr(gethostbyname($_),AF_INET))'
metafilter.com

'ip2hostname' just adds the ability to search through a file to find the IPs and allows you to format exactly how you want them translated. I don't know enough of Windows to be of much further help...
posted by zengargoyle at 1:10 PM on October 25, 2010


Best answer: for /f %a in (list.txt) do ping -a %a -n 1 | find "Pinging" >> output.txt
posted by panmunjom at 1:12 PM on October 25, 2010


upon further review, each host will get pinged once (the -n 1 argument). It'd be even better to add -w 100 so that you're not waiting the full 4 seconds for a dead host to get skipped.

use this: ... ping -a %a -n 1 -w 100 ...
posted by panmunjom at 1:20 PM on October 25, 2010


Response by poster: panmunjom, thank you you are a hero!

And thanks to everyone else too, I really appreciate the help.
posted by Carillon at 1:30 PM on October 25, 2010


« Older Is it hard to move a blog around within a website?   |   Help me animate like it's 1999 Newer »
This thread is closed to new comments.