IP to DNS Conversion Tool? Does such a thing exist?
11 replies, posted
I have a list of IP's that I need to convert to DNS or NetBIOS names. Does such a tool exist? Doing ping -a <ipaddress> 150 times is not something I want to do...
Well.. I guess I could try writing something like this, I'll make it read from input.txt and write to output.txt, somewhat like that.
[QUOTE=WeltEnSTurm;32827826]Well.. I guess I could try writing something like this, I'll make it read from input.txt and write to output.txt, somewhat like that.[/QUOTE]I've tried writing a batch file, but all it does is repeat the ping -a <ipaddress> command over and over again.
Can't think of a Windows tool, but on Linux you could nslookup all the IP's, grep the results out and pipe them into a file.
It's all stdin/stdout with standard UNIX tools so it's doable.
I can't figure out how to give nslookup more than one IP to resolve at a time, so you'd have to do a for-loop, loop through a file that has the IP's in it and pass the IP as an argument every time.
To be honest, not sure how to do that, but someone smarter than me can probably figure it out.
Or suggest another tool.
[QUOTE=nikomo;32828152]Can't think of a Windows tool, but on Linux you could nslookup all the IP's, grep the results out and pipe them into a file.
It's all stdin/stdout with standard UNIX tools so it's doable.
I can't figure out how to give nslookup more than one IP to resolve at a time, so you'd have to do a for-loop, loop through a file that has the IP's in it and pass the IP as an argument every time.
To be honest, not sure how to do that, but someone smarter than me can probably figure it out.
Or suggest another tool.[/QUOTE]What's the proper way of dumping that into a batch file? I have it in an Excel spreadsheet so it should be easy to work with.
[url]http://localhostr.com/files/aOTCXZv/iptodomain.exe[/url]
Can't figure out how to get the hostname directly in C++, so this is all I can do.
Here's the source:
[cpp]
#include <windows.h>
#include <iostream>
#include <fstream>
int main(int argc, char* argv[]){
std::ifstream fileIn("input.txt");
if(!fileIn.is_open()) return 1;
while(fileIn.good()){
std::string line;
std::getline(fileIn, line);
system(("ping -a " + line + " -n 1 -w 1").c_str());
}
system("pause");
return 0;
}
[/cpp]
[QUOTE=WeltEnSTurm;32828535][url]http://localhostr.com/files/aOTCXZv/iptodomain.exe[/url]
Can't figure out how to get the hostname directly in C++, so this is all I can do.
Here's the source:
[cpp]
#include <windows.h>
#include <iostream>
#include <fstream>
int main(int argc, char* argv[]){
std::ifstream fileIn("input.txt");
if(!fileIn.is_open()) return 1;
while(fileIn.good()){
std::string line;
std::getline(fileIn, line);
system(("ping -a " + line + " -n 1 -w 1").c_str());
}
system("pause");
return 0;
}
[/cpp][/QUOTE]Yeah, nothing happens when I open that.
Paste your IPs in a file called input.txt, one IP per line.
[QUOTE=WeltEnSTurm;32828695]Paste your IPs in a file called input.txt, one IP per line.[/QUOTE]That worked. It's running now. Thanks man.
[editline]17th October 2011[/editline]
Not getting an output file, and it seems to have started at the beginning of the list.
Why can't you use nslookup? I guess Windows makes it annoying to parse the results as usual, but it will resolve the PTR records fine.
EDIT: Maybe you could try dig for Windows. It might have flags to clean up the output enough.
for /f "tokens=1 delims=[]" %%a in ('find /v "" ^< myfile.txt') do (
echo "Testing: %%a ">>response.txt
ping -a %%a>>response.txt
)
You can get rid of the "echo" line if you want. Just put that to show you how to make it save more text.
ARP -a to the DNS should give you a nice list
Sorry, you need to Log In to post a reply to this thread.