Controlling IIS IP Filtering Settings from ASP.Net

Posted on 2006-03-26
Medium Priority
Last Modified: 2008-02-01
I need to block an IP / IP Range for a specific Virtual directory in IIS.
While I can do this using IIS' built-in IP filtering feature, I find that it's basically a manual option.
I fancy doing the same using ASP.Net when my web application detects more than three failed attempts from the same IP,
I would like to have my application add the IP to IIS' filter list effectively blocking the user from accessing the application.

Ideas on:

1. Detecting multiple failed login attempts from the same IP / IP range
2. Accessing IIS IP filter list to deny access to resource
3. After a timeout, I might also need to "unblock" the IP / IP range

would be a great help.  Thanks in advance
Question by:v_bharghava
LVL 10

Expert Comment

ID: 16298668
If you are good in programming with .net  use System.Diagnostics Namespace class library which contains the Eventlog components to read the event log and log the ip which fails for three time contiuosly and block it.-

Also check this article to know abt brute force attacks
LVL 12

Accepted Solution

TheMegaLoser earned 1500 total points
ID: 16299382
I noticed that MSDN is probably protected to subscribers. See the following link instead:

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 16300910
"I fancy doing the same using ASP.Net when my web application detects more than three failed attempts from the same IP"

What's meaning? Do you control this through db?

Author Comment

ID: 16301409
TML has pointed out nicely to what I wanted to accomplish in bullet 2.
agiampy, that could be one of the approaches for accomplishing bullet 1 & 3.
Since I need to detect failed attempts from the IP, I may have to store all failed attempts somewhere.  
Eventlog approach suggested by "dnojcd" might not be appropriate here.  Database is a natural choice.  But what would the architecture of such a program would be?  Would it be a demon implemented as a Windows Service or a hread spwaned on Application_Start that iterates through the list of blocked IPs and according to the elapsed time unblocks blocked IP addresses?
LVL 12

Expert Comment

ID: 16302595
#1, How is the login performed? Are you using forms login or integrated windows authentication ? If you're using forms you can easily write to a database in your own code.

#3 can be solved by writing a small program that checks and clears the list. Then you just schedule it to run every hour.

Expert Comment

ID: 16304058
#1 You shuold use servervariables to detect what's the remote IP and verify if this IP has been failed the logon
#2 If it has been failed, you should add this to a table (BlackList) and save also date/time of failed logon
#3 When a remote user shuld be attempt to access your site, you just verify what is the IP (Request.ServerVariables("Remote_Addr")) and search it in the tabel BlackList. IF it is in table, verify the date/time, and delete the IP if "unblock" state. After this, repeat the #1.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Over time, the online landscape has altered considerably, but that’s nothing compared to the up-and-coming trends that will shape the web design industry in the coming year. Keep reading to find out which trends will shape B2B web design in 2018.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

809 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