asp.net-mvc - ipSecurity - 如何添加 IP 地址范围

标签 asp.net-mvc security web-config whitelist cidr

我们需要将 WAF 的 IP 地址范围列入白名单,如下:

199.83.128.0/21
198.143.32.0/19
149.126.72.0/21
103.28.248.0/22
 45.64.64.0/22
185.11.124.0/22 
192.230.64.0/18

更多细节:

https://incapsula.zendesk.com/hc/en-us/articles/200627570-Restricting-direct-access-to-your-website-Incapsula-s-IP-addresses-

我正在使用 .net ipSecurity 部分。但还没有找到任何如何添加上述 ip 地址而不必添加所有 ip 地址的示例。

例如

<ipSecurity allowUnlisted="false">
        <!-- this line blocks everybody, except those listed below -->
        <clear/>

        <add ipAddress="xx.xx.xx.xx" allowed="true"/>
      </ipSecurity>

我是子网掩码的新手。

有没有一种优雅的方式来实现这个?

最佳答案

在199.83.128.0/21中,21是子网掩码的CIDR格式。您可以使用 conversion table将 CIDR 格式转换为 IP 地址。

然后将您的 IPSecurity 设置为拒绝除指定 IP 地址之外的所有地址。即:

<security>
  <ipSecurity allowUnlisted="false">
    <add allowed="true" ipAddress="199.83.128.0"   subnetMask="255.255.255.240"/>
    [add additional ip addresses here]
  </ipSecurity>
</security>

关于asp.net-mvc - ipSecurity - 如何添加 IP 地址范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33906413/

相关文章:

asp.net-mvc - 从 Web 应用程序中删除已保存的浏览器用户名和密码

asp.net - 如何配置事件目录的连接字符串

c# - Asp.NET MVC4 Redirect(url) 抛出参数异常

android - 使用 Google 身份验证从 Android 客户端使用 WebAPI2 站点

c# - 动态扩展SQL语句-页面搜索

security - 针对非 SSL 表单发布到 SSL 的 MITM 攻击

security - s3 和 cloudflare 灵活的 ssl 握手

c# - 如何在 5 次不成功尝试后锁定用户帐户

c# - asp.net webforms 在代码隐藏中处理 404 notfound 错误?

c# - 使用 ImageGen 时出现类型或 namespace 错误