(407) 995-6628 /Login /Register

How to Block an IP Address in Plesk Using web.config Print

  • Plesk, ASP.NET
  • 171

Blocking an IP address on a Windows hosting server that uses Plesk can be done using the web.config file. The web.config file is a powerful XML file for configuring applications and controlling how they behave. In this article, we will outline how to use web.config to block specific IP addresses for users hosted with DataPacket or any other Windows-based hosting service that uses Plesk.


Prerequisites:

> A hosting account with Plesk on a Windows server.
> Access to Plesk's File Manager.
> The IP address(es) you wish to block.


Step 1: Access the File Manager

1. Log in to your Plesk control panel.

2. Navigate to the "Websites & Domains" section.

3. Find the domain you want to modify and click on "File Manager."

Step 2: Locate or Create the web.config File

1. In the File Manager, navigate to the root directory of your website; this is usually httpdocs or public_html.

2. Look for the web.config file. If it exists, click to select it, then click "Edit" in the top menu.

3. If the web.config file does not exist, you will need to create one. You can do this by clicking on "New", then "Create File". Name it web.config and ensure its extension is .config.

Step 3: Edit the web.config File to Block the IP Address

1. To block a specific IP address, you will need to add a rule in the web.config file under the <system.webServer> section. The XML code below shows how to block a single IP address:

<configuration>
<system.webServer>
<security>
<ipSecurity allowUnlisted="true"> <!-- this line allows all IPs by default -->
<add ipAddress="123.123.123.123" allowed="false"/> <!-- this line blocks the specified IP address -->
</ipSecurity>
</security>
</system.webServer>
</configuration>

> Replace 123.123.123.123 with the IP address you wish to block.

2. To block multiple IP addresses, add an <add> element for each IP address you wish to block:

<add ipAddress="124.124.124.124" allowed="false"/>
<add ipAddress="125.125.125.125" allowed="false"/>

3. To block an entire IP range, use the subnetMask attribute:

<add ipAddress="123.123.123.0" subnetMask="255.255.255.0" allowed="false"/>

> This will block all IP addresses from 123.123.123.0 to 123.123.123.255.

4. After adding the necessary IP block rules, make sure to save your changes. In Plesk's File Manager, you can usually do this by clicking "OK" or "Apply".

By taking these steps, you can secure your website hosted on a Windows server using Plesk by blocking unwanted IP addresses through the web.config file. Remember, incorrect configurations can lead to unexpected behaviors, so always backup your web.config file before making changes.


Was this answer helpful?

« Back

Copyright © 2001-2023 DataPacket. All rights reserved. All trademarks and registered trademarks are the property of their respective owners.