As with all websites, internal or public, it's important to know how to block access to individual IP addresses or IP address ranges. This can be useful to avoid unwanted traffic from bots or malicious users with known sources, or for blocking web crawlers that are ignoring your robots.txt file.
Within the DNN UI, you can block or permit users from logging into your instance but if you need to completely block access to your domains, you'll need to make changes to the DNN web.config file.
NOTE: The steps following will trigger an automatic application pool restart so it is advisable to do this outside of normal business hours. As a best practice, make sure to take a backup of your site before proceeding.
- Within your operating system, go to Control Panel > Administrative Tools > Internet Information Services (IIS) Manager.
- In the Connections menu to the left of the screen, click on the arrow icon to the left of your server name to expand the selection.
- Click on the arrow icon to the left of Sites to expand this selection.
- Right-click on the name of your DNN site and select Explore.
- In the folder explorer, find the file web.config and double-click to open in notepad.
- Press Ctrl+F and search for "system.webserver"
- Within this section, find the following (it should be around line 126 or 127.)
- Copy the following and insert in between the two lines in the above screenshot, customizing the IP addresses and subnet masks as needed:
<ipSecurityallowUnlisted="true"> <!-- this line allows everybody, except those listed below -->
<clear/> <!-- removes all upstream restrictions -->
<addipAddress="22.214.171.124"/> <!-- blocks the specific IP of 126.96.36.199 -->
<addipAddress="188.8.131.52"subnetMask="255.255.255.0"/> <!--blocks network 184.108.40.206 to 220.127.116.11-->
<addipAddress="18.104.22.168"subnetMask="255.255.0.0"/> <!--blocks network 22.214.171.124 to 126.96.36.199-->
<addipAddress="188.8.131.52"subnetMask="255.0.0.0"/> <!--blocks entire /8 network of 184.108.40.206 to 220.127.116.11-->
- Save the web.config file. This will automatically recycle the application pool and place the blocks in effect.
- Input your own IP address into the block list for your site using the steps above.
- Navigate to your specific DNN URL
- You should see a 403 Error Page
- Remove your own IP from the block list using the same steps.
- If your block works for you but you are still seeing unwanted traffic, ensure you have the correct IP for the unwanted party. You may also need to expand your block list subnet if the traffic comes from a dynamic IP range.