vnet576
Sep 3 2003, 12:20 AM
Has anybody here seen or heard of a tool that could convert many hostnames into ip addresses. For example say i get it a list of 100 websites that i need converted into ip addresses. I know there are plenty of tools where u gotta convert each one indivioduly, but with alot of hostnames that could take a long time.
hulk
Sep 3 2003, 12:53 AM
it would take a long time but u could ping each one and it would return the ip address from a web address
Gandalf^^
Sep 3 2003, 01:11 AM
a simple bat file would make it. here is a start:
| QUOTE |
echo off set file=%1 for /f %%i in (%file%) do ping %%i >> result.txt
|
I named it host_to_ip.bat
i tested it with a hostnames list host.txt so usage was
host_to_ip.bat host.txt
it outputs a file named result.txt that looks like this:
| QUOTE |
Pinging lns-p19-.......net [62.xxx.xxx.xxx] with 32 bytes of data: Request timed out. Request timed out. Request timed out. Request timed out. Ping statistics for 62.xxx.xxx.xxx: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Pinging A.......aol.com [172.xxx.xxx.xxx] with 32 bytes of data:
Reply from 172.xxx.xxx.xxx: bytes=32 time=611ms TTL=117 Reply from 172.xxx.xxx.xxx: bytes=32 time=643ms TTL=117 Reply from 172.xxx.xxx.xxx: bytes=32 time=681ms TTL=117 Reply from 172.xxx.xxx.xxx: bytes=32 time=660ms TTL=117 Ping statistics for 172.xxx.xxx.xxx: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 611ms, Maximum = 681ms, Average = 648ms |
you can now easily extract automatically the IP and the host from the file by only selecting the first line of each ping : "Pinging A.......aol.com [172.xxx.xxx.xxx] with 32 bytes of data"
if you only need the ip and don't need anymore the host, it'll be easy to make another batch file that only outputs the ips.
hope it can help
edit: stupid @ removed behind echo
vnet576
Sep 3 2003, 01:27 AM
Wow that was a good idea...thanks for your help. Haven't thought about using a batch file. It does everything that i need.
agamemnon
Sep 3 2003, 01:30 AM
This should work like a dream, and produce far smoother output than Gandalf's. Sorry!
NAMES.BAT
| CODE |
for /f %%i in (ips.txt) do ping -a -n 1 %%i | FIND /i "Pinging" >> result.txt
|
IPS.TXT
| CODE |
192.168.0.11 192.168.0.12 192.168.0.13
|
Sample output:
Pinging TJA [192.168.0.11] with 32 bytes of data:
Pinging ROUTER [192.168.0.12] with 32 bytes of data:
Pinging fred [192.168.0.13] with 32 bytes of data:
Gandalf^^
Sep 3 2003, 01:49 AM
thanks for the improvement, I never used the switches with ping.
vnet576
Sep 3 2003, 01:49 AM
hehe..that one works even better, thanks.
Both of u saved me alot of time with these batch files.
woutiir
Sep 3 2003, 08:20 AM
Here's a small perlscript i made for resolving.
just start it like this:
perl resolve.pl <file with ips>
| CODE |
#!/usr/bin/perl
use Socket;
open(FILE, $ARGV[0]); @domains = <FILE>; close(FILE);
foreach $domain (@domains) { chomp($domain); if($domain) { /* print $domain.' '; */ $ipaddr = gethostbyname($domain); if($ipaddr) { printf "%s\n" , inet_ntoa($ipaddr); } else { print "Cannot be resolved\n"; } } }
|
And how the file should look like:
| CODE |
www.google.com www.governmentsecurity.org www.woutiir.org
|
etc..

Try it!
woutiir..
Output is as you'd like it
vnet576
Sep 3 2003, 07:34 PM
I've never used pearl before. What exactly do i have to install in order to run that script and how do i compile it.
woutiir
Sep 4 2003, 01:14 PM
Just use linux. I dunno exactly how to use it under windows. I'd recommend:
http://www.google.com for those questions

Linux it's simple:
perl <program.pl> and it runs

Greetings,
woutiir
agamemnon
Sep 4 2003, 02:46 PM
You can download ActivePerl. It runs under windows. I use it all the time. Google for it.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.