2

我想阻止指定范围的 IP 地址。我已将 web.config 文件中的代码编写为:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
  <security>
    <ipSecurity allowUnlisted="false"></ipSecurity>
  </security>
</system.webServer>

这将阻止一切。

但是当我运行这段代码时,没有任何东西被阻塞。

4

2 回答 2

2

I suggest you to take a look at the answer to the following question, maybe it can help you:

"I doubt you can do that at the web.config level unless the "IP and Domain Restrictions" role is installed on the server itself."

Web.config 500 block ipaddress - Internal server error

Even if you're not getting the 500 error, maybe you just have to add the:

<clear/>

to remove all upstream restrictions? Let me know.

EDIT: added instructions to configure Restriction access to websites using IP address in IIS 7.

Here's a good link, explaining how to install "IP and Domains restrictions" in IIS 7, as this feature is not installed by default. If you don't install this feature, restrictions won't work!

http://linuxwebservertips.in/restrict-access-to-website-using-ip-address-in-iis-7/

Follow this guide and everything will work fine, As you can see, you can add multiple range restrictions too.

于 2013-09-30T12:14:37.873 回答
0

这可能会有所帮助。我在无法访问 IIS 的站点上使用它。它成功地阻止了单个 IP 地址。它可能可以修改为阻止范围。

http://www.hanselman.com/blog/AnIPAddressBlockingHttpModuleForASPNETIn9Minutes.aspx

于 2013-10-21T06:19:31.997 回答