您的当前位置:网站首页 » 帮助中心 » 正文内容

知识:网站通过配置web.config屏蔽IP访问

  将以下代码复制另存为web.config文件,其中的IP可以替换和增加为需要屏蔽的IP,支持IP段屏蔽,上传到网站根目录即可生效。(仅限windows IIS系统)

 
 
需要屏蔽的IP地址只需要在文件中增加一行 <add ipAddress="需要屏蔽的IP"/>保存即可。
 
其中 <add ipAddress="127.255.255.0" subnetMask="255.255.255.0"/> 表示屏蔽了整个 127.255.255.0/24 段的访问
 
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
<security>
   <ipSecurity allowUnlisted="true">
       <clear/>
       <add ipAddress="127.0.0.1"/>
       <add ipAddress="127.255.255.0" subnetMask="255.255.255.0"/>
   </ipSecurity>
</security>
</system.webServer>
</configuration>