Andrew Pallant

Software & Web Developer

 

Banning IP Addresses

Published: Feb 08, 2011 21:44:00
Physical Link: Banning IP Addresses


Today I was hammered by the Amazon Cloud every second until I modified my web site.  Ideally you would block this activity in your firewall, but I use a hosting company who will not do this for me.  The code below is what I had implemented and seems to work well.   I had placed this in my global.asax file in the session_start routine.

String strClientIP = Request.UserHostAddress;
if (strClientIP.Equals(“204.236.242.185″) || strClientIP.Contains(“50.16.”) || strClientIP.Contains(“50.19.”)) 
{
          HttpContext.Current.Response.Redirect(“http://www.google.com”);

}

Good luck to everyone, who has this happen to them.


Filed under: Uncategorized