【问题标题】:Add IP programmatically to ipv4 and domain restriction以编程方式将 IP 添加到 ipv4 和域限制
【发布时间】:2012-10-11 13:51:03
【问题描述】:

任何人都知道如何使用 vb.net 以编程方式将 IP 地址添加到 IIS7 中的“IPv4 和域限制”中。

即我想排除某些 ip 或 IP 范围访问我服务器上的某些文件夹并允许某些用户访问它。

我发现了那些不错的文章:

http://www.iis.net/configreference/system.webserver/security/ipsecurity/add

https://serverfault.com/questions/305681/iis-7-address-restrictions-importing-list-to-block-china-and-korea-ips

http://www.tuicool.com/articles/uQru6v

【问题讨论】:

    标签: vb.net iis-7 windows-server-2008 appcmd


    【解决方案1】:

    也许你可以通过执行一些命令行工具来添加限制。

    (以下信息是从 Microsoft IIS 文档中复制粘贴的)
    配置 IPv4 地址和域名允许规则 (IIS 7) (Original document here)

    要为 IPv4 地址和域限制创建允许规则,请使用 以下语法:

    appcmd set config /section:ipsecurity /+"[ipaddress=' string ',allowed='true',subnetMask=' string ',domainName=' string ']"
    

    变量 ipaddress 字符串是单个 IPv4 地址。变量 subnetMask 字符串是子网掩码。组合使用子网掩码 使用 IPv4 地址来标识适用于 这个规则。变量域名字符串是一个域名。通常 您会使用 IP 地址或域名,但不能同时使用 规则。

    例如,要为 IPv4 地址 10.0.0.1 创建允许规则,请键入 在命令提示符下输入以下内容,然后按 ENTER:

    appcmd set config /section:ipsecurity /+"[ipaddress='10.0.0.1',allowed='true']"
    

    有关 Appcmd.exe 的详细信息,请参阅Appcmd.exe (IIS 7).

    更新 要执行该命令,您可以使用如下代码

    Sub MySubName
        Process.Start("C:\Windows\System32\inetsrv\appcmd set config yada-yada-yada...")
    End Sub
    

    我从未使用过 appcmd 命令行工具,因此您需要查看文档并了解如何使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-20
      • 2014-07-20
      相关资源
      最近更新 更多