Solved

DNS Lookup with IP address

Posted on 1998-08-07
22
12,680 Views
Last Modified: 2013-12-25
I have an ip address ###.###.###.### and i want the "friendlier" name for it www.friendlyname.com... How can I do that in ASP?  Source Code please... Please don't post an answer that says "YOu can't"... Thanks.

- Matt
0
Comment
Question by:MasseyM
  • 8
  • 7
  • 7
22 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 1858881
Install perlscript for ASP and then the code is:

<script language=PerlScript RUNAT=Server>
sub GetDomainName
{
      $RemoteHost = gethostbyaddr(inet_aton($ENV{REMOTE_ADDR}),AF_INET);
      return $RemoteHost;
}
</script>
<%
DomainName = GetDomainName()
%>



0
 
LVL 10

Author Comment

by:MasseyM
ID: 1858882
I dont have access to install Perscript.. Any way via ASP?
0
 
LVL 28

Expert Comment

by:sybe
ID: 1858883
Perlscript can be used in ASP, just as you can use VBScript or Javascript.

So perlscript IS ASP :)

Probably yo mean if there is a way in VBScript. The thing is that you have to do some reverse DNS-lookup. You could try and write the VBScript for that your self, or use those which are available.

- Available is the perl routine (if you have perl & perlscript installed
- available is NS-lookup (if you have that installed on your machine). It runs from the command prompt. You could try to use that by calling it from ASP and make it write to a small file on HD, read that file and get the domainname from it. It is not a very elegant way, but it works (i have used it, but not with ASP)

If you would like to have source code for that, I don't have it, you would have to give more then 50 points to make me work on that. You can probably figure the code out yourself.

0
 
LVL 28

Expert Comment

by:sybe
ID: 1858884
There was something missing in the code using perlscript, so I'll post the working code here, for those who are interested.

Another solution on which I am working is to make a COM object using java, and call that from the ASP. Using java it should be too hard to get the domain name based on the IP address, since java (just like perl) is web-oriented and has inbuilt function for such things.

When I have that working i'll post the java-code and the procedure of registering it at as a COM-object so it can be accesed through ASP.

Anyway, here's the working code with perlscript (it needed a "use Socket" statement).

<script language=PerlScript RUNAT=Server>
use Socket;

sub GetDomainName
{
      $RemoteHost = gethostbyaddr(inet_aton($ENV{REMOTE_ADDR}),AF_INET);
      return $RemoteHost;
}
</script>

<%
DomainName = GetDomainName()
Response.write DomainName
%>


0
 
LVL 10

Author Comment

by:MasseyM
ID: 1858885
ok, Still no one understands... I DON NOT have Perscript on my server... I will not have it either.  So, there is no way to do it other than with perl?
0
 
LVL 10

Author Comment

by:MasseyM
ID: 1858886
ok, Still no one understands... I DON NOT have Perscript on my server... I will not have it either.  So, there is no way to do it other than with perl?
0
 
LVL 4

Expert Comment

by:mitek
ID: 1858887
Well, actually, you could write an ASP component using C++ and ATL. But again, you won't be able to install it since you don't have access to your server configuration. And VBScript will not allow you to do many things ...
Usually, when one has to do something fancy in VBScript, it's time to write an ATL ActiveX (server-side) component. And PerlScript is just a simplest way around that problem, because it's already sort of an ActiveX component.

We once wrote such a component, one that did something that VBScript could never do: connect to a OWS 2.0 server (Oracle) and do transactions, like login, charge points, etc. We knew exactly that VBScript could never do that, so there was no questions like "how to do something like that in ASP ?"
There some limitations to VBScript that can't be resolved w/o resorting to a different level of technology. This seems to be one of them.
I suggest you accept sybe's answer -- it's very logical and by far the most simple.
0
 
LVL 28

Expert Comment

by:sybe
ID: 1858888
There should be another way: java, as I have pointed out.
The thing is that ASP and VBScript do not offer the functionality that you need for that, so you have to import that functionality from another programming language: perl or java then seem to be the best options, since those are very much internet oriented languages.

I have written a component in Java that does the trick. The only thing is that it bumps on a bug in java 1.02 (so in fact does not do the trick). I can't get it working on a win95 machine, but i'll hope i will get it working on NT4 (after the weekend, you'll have to wait).

By the way, MassyeM, the problem interests me, but your reactions are not very stimulating.

0
 
LVL 10

Author Comment

by:MasseyM
ID: 1858889
sybe, why do I not stimulate you? :)  I am not here to stimulate, I just need some answer ...
0
 
LVL 28

Expert Comment

by:sybe
ID: 1858890
MasseyM,

I gave you one working answer completely worked out and two suggestions of how to find another solution.

You have not reacted at all on the suggestions that I made. I will repeat them here:

1. Use NSlookup, this is an NT program that runs from the command prompt and does a reverse DNS lookup. Try to make it run with ASP and read the output. You might also try it with Ping, which also returns the domain-name.
2. Use java to make a class file that does the trick. Then register it as a component, so it can be called through ASP.

You could indicate if these suggestions are what you might be looking for, or that you can tell in advance that it is out of the question.

Is NSLookup installed on the machine ?
Can you compile javacode ? you can download compilers for free (or is that too much trouble).
Can you register a component ? or don't you have access for that ?

0
 
LVL 10

Author Comment

by:MasseyM
ID: 1858891
OK, sybe, answer the question and you get the points... I don't care anymore.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 4

Expert Comment

by:mitek
ID: 1858892
I think I have a solution for that problem.
It's an ASP component, that should be used in the following way:

=====================================<BR>
<%
  Set obj = CreateObject("DNS.Lookup")
  hostname = obj.GetNameByIP("204.178.210.195")
  error_text = obj.GetErrorText
  Set obj = Nothing
%>

<%=hostname%>
<BR>
Error: <%=error_text%>

<BR>
======================================
<BR>

If you're interested, tell me what you think about it.

You don't have to accept my answer, until you see the component. Besides, this answere will definitely cost more than 50 points (maybe, not much more, though)

0
 
LVL 28

Expert Comment

by:sybe
ID: 1858893
mitek,

you make me curious, did you make that component yourself ? And what did you use to make it.

I have mine finished too, but I don't get it working on PWS/Windows95, although it should. I'll have to try it on a NT machine. I used Java to do it.

0
 
LVL 4

Expert Comment

by:mitek
ID: 1858894
Yep. I wrote it just for fun, in Visual C++ with using ATL library. Not that I really cared about answering that particular question, I just wanted to refresh my knowledge of ATL. And it worked :)
I can send you the source code, if you want. It's not a space shuttle, quite simple.
0
 
LVL 10

Author Comment

by:MasseyM
ID: 1858895
Sounds good, but I DONT HAVE ACCESS to install the component... Does it have to be installed into ther server, or can I just create an instance from the ASP source?  -- How much more?

- Matt
0
 
LVL 4

Expert Comment

by:mitek
ID: 1858896
Yep. I wrote it just for fun, in Visual C++ with using ATL library. Not that I really cared about answering that particular question, I just wanted to refresh my knowledge of ATL. And it worked :)
I can send you the source code, if you want. It's not a space shuttle, quite simple.
0
 
LVL 4

Expert Comment

by:mitek
ID: 1858897
short answer:
if you can run
regsrv32 component.dll (in other words, to register a component) on the server, you can install it.
If you can't, sorry -- you can't.
(don't worry, i have a feeling it won't go on much longer)

whatever happens -- i'm making my component a shareware thingy.
if someone needs it in the future, it'll be there

the main point, it IS possible. for those, who have access to the server.

0
 
LVL 4

Expert Comment

by:mitek
ID: 1858898
(sigh. i guess, he didn't like my last remark. i feel rejected :)
0
 
LVL 28

Expert Comment

by:sybe
ID: 1858899
mitek,

yep, i'd like to have the source code for your thing.

If you're interested, I'll send you mine. The only thing is I still haven't got it working: the problem now is that IIS4 treats java differently. *sigh*.


0
 
LVL 4

Expert Comment

by:mitek
ID: 1858900
I'll put it to http://www.sarov.com/downloads/lookup.zip
My email is mitek@i3tele.com -- you may send me Java solution if you want.


0
 
LVL 28

Accepted Solution

by:
sybe earned 50 total points
ID: 1858901
MasseyM,

Ok, I'll answer the question. With the remark that a mitek in not the only one who programmed a working component for DNSLookup.

See:
http://www.serverobjects.com/products.htm#aspdns

I have given up temporarily my efforts to make the java-component working on IIS4.
0
 
LVL 10

Author Comment

by:MasseyM
ID: 1858902
You get the points only because you tried very hard.  You got a B only because you were persistant... Please help me get a working example and I will repost another question worth a lot more...
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This video teaches users how to migrate an existing Wordpress website to a new domain.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now