How to stop a 'Denial Of Service' (DoS) attack on your ASP.NET web site, aka "Using the 'Dynamic IP Restrictions' IIS Extension on Windows Azure with a Startup task"
A few days ago our team spent some time stress testing our web services.
We divided the team into 'Attackers' and 'Defenders' - the attackers' goal was to generate traffic that would bring down our system, the defenders' goal to understand the attacks and come up with innovative ways to block them - our team leader called this 'War Games'.
If you're under 25 and you don't know what 'War Games' is, you just
pissed me off; see http://en.wikipedia.org/wiki/WarGames
One of the early attacks involved the user of JMeter (http://jmeter.apache.org/ ) - you don't need much CPU or bandwidth to generate tons of GET requests - and we found that a couple of users running JMeter with a broadband connection could hit our servers hard with literally thousands of requests per second - causing invalid and unnecessary traffic
![]()
A stress test client that can be used nefariously -
JMeter: http://jmeter.apache.org/
After doing some research, our team (the 'Defenders') came up with a couple of ideas on how to block such traffic. One of these ideas made use of an IIS extension provided by Microsoft called "Dynamic IP Restrictions", which I'll call from now on "Dynamic IP".
![]()
IIS Extension: http://www.iis.net/download/dynamiciprestrictions
The 'Dynamic IP' IIS extension is provided as a MSI installer - since our services are deployed to Windows Azure, we found that we needed to use Azure "Startup Tasks" to properly install and configure the extension on our virtual machines in the cloud.
Below I show in detail -
- Local Development in IIS - how to download, install and configure the 'Dynamic IP' extension when using a local instance of IIS.
- Command Line Configuration - how to configure the IIS extension using the command line.
- Local Development in Emulator and Azure Startup Tasks - how to make sure the extension works when running in the local Windows Azure emulator and how to ensure the installation of the extension doesn't run every time you run in the emulator locally.
- Deployment to Cloud - Window Azure Fabric - how to deploy, install and configure the extension to in the cloud and how to verify it works when running in Windows Azure VM instances.
A few notes to hopefully avoid some trolls -
- This won't stop all denial of service attacks, but that doesn't mean that we should do nothing - and end up at the mercy of all attacks.
- I write these tutorials to contribute to the .NET community - as a buddy once told me: "your stuff is what we should be seeing on MSDN"; that made me happy - but I'm always looking for constructive criticism on the content or style.
- As always, my posts contain tons of screenshots - that saves me tons of typing but also ensures all steps are covered.
Hat tip to my co-worker Matthew T. who did a lot of this work and came up with some of the solutions below.









