Blocking IP Addresses

From Hostek.com Wiki
Revision as of 23:23, 22 July 2012 by Kaseya (Talk | contribs) (Created page with "==Windows== ===Using your web.config file to block IP Addresses=== To block a specific IP or a large range of IP Addresses you can use your "web.config" file by following the...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Windows

Using your web.config file to block IP Addresses

To block a specific IP or a large range of IP Addresses you can use your "web.config" file by following the below steps.

  • If you do not have a web.config file in your site files then you will need to create one at this time. The code below is the basic code you would see in your web.config file:
<?xml version="1.0"?>
<configuration>
   <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
   </system.webServer>
</configuration>

To enable the block you will need to place the below code after the "<system.webServer>":

<security>
   <ipSecurity allowUnlisted="true">    
       <clear/>                    
       <add ipAddress="1.1.1.1"/>     <!-- blocks the specific IP of 1.1.1.1  -->                
       <add ipAddress="1.1.1.0" subnetMask="255.255.255.0"/>     <!--blocks network 1.1.1.0 to 1.1.1.255-->                
       <add ipAddress="1.1.0.0" subnetMask="255.255.0.0"/>     <!--blocks network 1.1.0.0 to 1.1.255.255-->                
       <add ipAddress="1.0.0.0" subnetMask="255.0.0.0"/>     <!--blocks entire /8 network of 1.0.0.0 to 1.255.255.255-->                
   </ipSecurity>
</security>

Once you update this code to the specif IP Addresses you are trying to block and click save any attempts from these IP's to hit the site will not go through.

Linux

Blocking IP Addresses through Cpanel

You will need to be logged into your Cpanel for your domain. Once logged in:

  1. You will click on "IP Deny Manager".
  2. Now you will see an option to add an IP Address or Domain to the block list.
  3. Once you enter the desired IP Address you should receive a message that states:
    "Users from the IP address(s) 12.34.56.789 will not be able to access your site."