Message Board

http:BL Use/Development

Older Posts ]   [ Newer Posts ]
 How to do a DNS Query in ASP
Author: B.Sporrong   (27 Apr 07 4:48am)
Well the subject is my question. Im not that hot at ASP but it's the only language I know anything about at all. So how do I go about if I want to compare an IP to the list?
 Re: How to do a DNS Query in ASP
Author: M.Towler   (27 Apr 07 7:41am)

^^ That will retrieve the host address that you are after but if you want to compare it to a list then you could stick the list into an array and then just do a select statement or maybe even just a loop to check each part of the array against the retrieved IP address and then exit the loop after you get a match....
Dim StrBLkey
Dim strLookup

StrBLkey = "rggcssbjrlbs"
strLookup = StrBLkey & "." & StrReverse(Request.ServerVariables("REMOTE_ADDR")) & ""
THat code will retrieve the IP address, but atm im unsure how to compare it to a dns, sorry if this doesnt help

Post Edited (1 May 07 6:10am)
 Re: How to do a DNS Query in ASP
Author: B.Sporrong   (27 Apr 07 8:07am)
Well, maybe it can set me on the right path anyway. Thanks!
 Re: How to do a DNS Query in ASP
Author: M.Prince   (27 Apr 07 12:20pm)
Thanks for the code. Make sure you edit out your Access Keys when you post anything.
 Re: How to do a DNS Query in ASP
Author: M.Janssen   (29 Apr 07 8:37am)
The code is incorrect. StrReverse will (as far as I know) reverse the whole IP and not the just the octets.
 Re: How to do a DNS Query in ASP
Author: M.Towler   (1 May 07 6:10am)
If that is true then all you would need to do is strip the IP address into the octets and then re-order then.... and REMOTE_HOST is the DNS name for the ip address it would be REMOTE_ADDR
Try this i have tested it and it works :)

'Created by Marc Towler (
'Available for free use, do not remove this header

Dim StrBLkey
Dim strLookup
Dim strIP
Dim strOct1, strOct2, strOct3, strOct4
StrBLkey = "KEY HERE"
strIP = Request.ServerVariables("REMOTE_ADDR")
strOct1 = Left(strIP,3)
strOct2 = Mid(strIP,4,4)
strOct3 = Mid(strIP,8,3)
strOct4 = Right(strIP,3)
strNewIP = strOct4 & strOct3 & strOct2 & "." & strOct1
strLookup = StrBLkey & "." & strNewIP & ""

Post Edited (2 May 07 6:26pm)
 Re: How to do a DNS Query in ASP
Author: E.Watts   (5 Oct 07 6:00am)
my way of getting the dns name in asp - and a way of doing the dns query


Dim WordArray
WordArray = Split(Request.ServerVariables("REMOTE_ADDR"), ".")
ipaddy=WordArray(3) & "." & WordArray(2) & "." & WordArray(1) & "." & WordArray(0)
set WordArray=Nothing
dnsquery=accesskey & "." & ipaddy & ""

' if you have serverobjects aspdns on the server then this will do the dns lookup:

Set DNSLook = Server.CreateObject("AspDNS.Lookup")
strRes = DNSLook.DNSLookup (dnsquery)
Set DNSLook =Nothing

this code splits the address

i have ferther code for analising the return information - testing it at the moment before i upload the full code.

any more info needed just ask

do not follow this link

Privacy Policy | Terms of Use | About Project Honey Pot | FAQ | Cloudflare Site Protection | Contact Us

Copyright © 2004–18, Unspam Technologies, Inc. All rights reserved.

contact | wiki | email