0

I am trying to convert a VBScript COM component based Reverse/Forward IP checking system to C#.

This system was created to prevent the banning of SERPs like Googlebot using what was back then (becoming) the standard way of checking an IP was who it said it belonged to e.g a reverse/forward DNS check.

Although we have lists of SERP IP Ranges so we don't ban them if they come in - even with hack vectors - we cannot keep up with new ranges being added all the time.

The process is based around this short example.

It is explained simply here > http://ipadmin.junkemailfilter.com/rdns.php

This has been working fine for ages in VBScript but now I am converting to .NET I am having issues where people have set their IP to resolve to "localhost" like this one 113.168.154.182 as you just get back your own DNS server, Virgin media, or if I run it from my PC with c# I get my own computer name. The IP is from Vietnam > http://www.geoiptool.com/en/?ip=113.168.154.182

Now I am trying to use .NET and this code.

But as I am using this code to do get the hostname

IPHostEntry DNSHostIP = Dns.GetHostEntry("113.168.154.182");
hostname = DNSHostIP.HostName;

When I output the value of hostname I get my own computers name e.g std36w7.metal.mycompany.co.uk not localhost.

Then when I try and do a forward DNS check to get the list of IP addresses with this hostname I get my own IP addresses (one IPv6 one IPv4).

If I could get back "localhost" then I could have a check to skip it as a spoof along with anything starting with 10 or 192 etc.

However at the moment I cannot do this.

What is the best way of doing reverse/forward DNS checks which I thought was becoming the standard way of checking for spoofers nowadays in .NET?

And how can I handle people who have set (or some mistake might be causing it) their IP to be localhost.

Thanks

MonkeyMagix
  • 677
  • 2
  • 10
  • 30
  • 1
    TL;DR; - Please consider removing long story about you spam/bot detection/creation/whatever and just keep what you trying to achieve/have problem with. – Alexei Levenkov Feb 18 '15 at 18:03
  • ok well I've shortened it but the story was relevant as it explained WHY we had to use this kind of process. No-one wants to block SERPS from crawling their sites just bad bots – MonkeyMagix Feb 19 '15 at 11:07
  • I'm still not sure what you have problem with, sorry - hopefully with this smaller version someone will be able to help you... I assume you've seen [Get local IP](http://stackoverflow.com/questions/1069103/how-to-get-my-own-ip-address-in-c) question and know that normally only one IP (127.0.01) is mapped to "localhost" DNS entry... – Alexei Levenkov Feb 19 '15 at 15:27
  • Well in .NET I get both the IPv6 and IPv4 addresses. But Im not sure if this person is clever or stupid by putting his hostname as localhost as it means when I do a forward DNS check I get my own computer name back and also I don't want to ban my own localhost IP from accessing anything. I knew there was a standard way of checking if someones hostname really did belong to googlebot by doing a forward DNS, getting the IPS and checking against the original IP address. Wanted to know if that was still the standard for confirming a BOT was real or a spoofer – MonkeyMagix Feb 20 '15 at 10:35
  • SO is not the bes place to find answer to your actual question. You probably want to ask non-coding part of your question on http://webmasters.stackexchange.com/help/on-topic or maybe serverfault and than come back to SO if need help with technical details. Side note: I suspect you use "localhost" as synonym of "local host", not DNS name - sorry for misunderstanding. – Alexei Levenkov Feb 20 '15 at 17:37
  • Well its the actual name of the host / server, that this IP address returns when doing a reverse IP check "localhost" which is your local machines IP 127.0.0.1 in IPv4. I have come up with a solution that just ensures any local IP addresses e.g localhost, 192, 10. etc are ignored and never banned. As for the correct way to get info on checking BOTS out this was the way provided by blogs some years back e.g http://blog.strictly-software.com/2009/02/job-rapists.html but yes its probably more of a genral webmaster question than a techie one. – MonkeyMagix Feb 23 '15 at 09:57

1 Answers1

0

Simple. Your LOCAL DNS (guessing your router unless you have your own DNS server) is resolving it - upstream to it's INTERNET DNS server. Also if you really want it to return LOCALHOST, you'd have to literally edit your local HOSTS file and add an entry since no system ever returns the name LOCALHOST when you look up your ip even from a local DNS server. I believe the ONLY example is if you completely eliminate a DNS server to fallback on your local HOSTS file.

Collin Chaffin
  • 872
  • 9
  • 15