Forum Moderators: open

Message Too Old, No Replies

Need to perform a forward / reverse DNS lookup

         

Vimes

9:04 am on Dec 12, 2007 (gmt 0)

10+ Year Member



Hi,

does any one know or can they point me in the right direction on how i can perform this on a iis web server?

I'll even buy a tool if its out there ;)

Vimes.

Vimes

11:27 am on Dec 12, 2007 (gmt 0)

10+ Year Member



Just to clarify what issues I'm having:

All my pages are static, i would like to perform a lookup and allow access depending on the results returned.

Can any one help me with this problem.

Vimes.

carguy84

2:50 am on Dec 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey Vimes, you can use the code below to get the reverse DNS entry of the remote IP:

Dim strReverseDNS As String = ""
Try
strReverseDNS = System.Net.Dns.GetHostByAddress(Request.ServerVariables("REMOTE_ADDR")).HostName
Catch exc As Exception
strReverseDNS = Request.ServerVariables("REMOTE_ADDR")
Finally
End Try

It is VERY important to keep this in the Try/Catch block as there is a coding error in the .Net Framework which will error out if the IP address is xx.xx.x x x.x x x

Because you are using static html pages, you'll need to place this code in the global.asax file which needs to reside in your root application directory. If you don't have one, you will need to add it in.

Here's a good article on creating one and the different events that can get fired from inside of it:
[articles.techrepublic.com.com...]

You'll want to place your reverse dns code in the "Application_BeginRequest" sub.

Chip-

Vimes

6:56 am on Dec 13, 2007 (gmt 0)

10+ Year Member



Thanks Chip,

I'm looking at it now and I'll report back (hehe) when i have questions ;)

Vimes.

Vimes

10:12 am on Dec 14, 2007 (gmt 0)

10+ Year Member



Hi Chip,

setting up the global.asax file and running my static pages through it unfortunately doesn't want to work after a period of time the web server grinds to a holt and we have to restart, we do have fairly high traffic website would this be the reason or can you think of something that i might have messed up.

Vimes.

[edited by: Vimes at 10:13 am (utc) on Dec. 14, 2007]

carguy84

6:14 pm on Dec 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



can you copy and paste your global.asax file here?

Vimes

7:23 am on Dec 20, 2007 (gmt 0)

10+ Year Member



Hi Chip,

Thanks for your reply and willingness to help,

we've found an alternative method where we are using isapi to send to a asp script that opens the gate if they pass.

Once again thanks very much for your comments and help.

Vimes.