IP セキュリティ <ipSecurity>

  • 概要
  • 互換性
  • セットアップ
  • 方法
  • 構成
  • サンプル コード

※本ページに挿入されている画像をクリックすると、画像全体が別ウィンドウで表示されます。

概要

<ipSecurity> 要素は、インターネット インフォメーション サービス (IIS) 7.0 における IP ベースのセキュリティ制限の一覧を定義します。これらの制限は、IP バージョン 4 のアドレス、IP バージョン 4 のアドレス範囲、または DNS ドメイン名に基づいて設定できます。

互換性

  IIS 7.0 IIS 6.0
注意 <ipSecurity> は IIS 7.0 で新たに導入された要素です。

<ipSecurity> 要素は、IIS 6.0 の IPSecurity メタベース プロパティに代わるものです。

セットアップ

IIS 7.0 の既定のインストールには、IP セキュリティの役割サービスは含まれません。IIS で IP セキュリティを使用するには、次の手順に従って役割サービスをインストールする必要があります。

Windows Server 2008

  1. タスク バーで [スタート] ボタンをクリックし、[管理ツール] をポイントして [サーバー マネージャー] をクリックします。

  2. [サーバー マネージャー] ウィンドウのツリー表示で、[役割] を展開して [Web サーバー (IIS)] をクリックします。

  3. [Web サーバー (IIS)] ウィンドウで、[役割サービス] セクションまでスクロールして [役割サービスの追加] をクリックします。

  4. 役割サービスの追加ウィザードの [役割サービスの選択] ページで、[IP およびドメインの制限] を選択して、[次へ] をクリックします。

    拡大

  5. [インストール オプションの確認] ページで [インストール] をクリックします。

  6. [結果] ページで [閉じる] をクリックします。

Windows Vista

  1. タスク バーで [スタート] ボタンをクリックし、[コントロール パネル] をクリックします。

  2. コントロール パネルで、[プログラムと機能][Windows の機能の有効化または無効化] の順にクリックします。

  3. [Internet Information Services][World Wide Web サービス][セキュリティ] の順に展開します。

  4. [IP セキュリティ] を選択して、[OK] をクリックします。

    拡大

方法

IP 制限を追加して Web サイトへのアクセスを拒否する方法

  1. タスク バーで [スタート] ボタンをクリックし、[管理ツール] をポイントして [インターネット インフォメーション サービス (IIS) マネージャー] をクリックします。

  2. [接続] ウィンドウで、当該サーバー名を展開して [サイト] を展開し、IP 制限を追加するサイト、アプリケーション、または Web サービスを展開します。

  3. [ホーム] ウィンドウで [IPv4 アドレスおよびドメインの制限] 機能をダブルクリックします。

    拡大

  4. [IPv4 アドレスおよびドメインの制限] 機能で、[操作] ウィンドウの [拒否エントリの追加] をクリックします。

    拡大

  5. 拒否する IP アドレスを入力して [OK] をクリックします。

    拡大

Web サイトの IP 制限機能設定を編集する方法

  1. タスク バーで [スタート] ボタンをクリックし、[管理ツール] をポイントして [インターネット インフォメーション サービス (IIS) マネージャー] をクリックします。

  2. [接続] ウィンドウで、当該サーバー名を展開して [サイト] を展開し、IP 制限を追加するサイト、アプリケーション、または Web サービスを展開します。

  3. [ホーム] ウィンドウで [IPv4 アドレスおよびドメインの制限] 機能をダブルクリックします。

    拡大

  4. [IPv4 アドレスおよびドメインの制限] 機能で、[操作] ウィンドウの [機能設定の編集] をクリックします。

    拡大

  5. 未指定のクライアントに対する既定のアクセス動作を選択し、ドメイン名で制限を有効にするかどうかを指定して、[OK] をクリックします。

    拡大

構成

ルールは、一覧に示された順番に、上から下に処理されます。allowunlisted 属性は最後に処理されます。インターネット プロトコル セキュリティ (IPsec) 制限のベスト プラクティスは、拒否規則を最初に表示することです。allowunlisted 属性が false に設定されている場合は、この属性を消去できません。

IIS 7.0 のルート ApplicationHost.config ファイルでは、次の既定の <ipSecurity> 要素が構成されています。この構成セクションは、<clear> 要素を使用している場合を除き、既定の構成設定を継承します。

<ipSecurity allowUnlisted="true" />

属性

属性 説明
allowUnlisted オプションの Boolean 属性。

一覧に登録されていない IP アドレスを許可するかどうかを指定します。allowUnlisted 属性を true に設定すると、一覧に登録されていない IP アドレスでサーバーにアクセスできるようになります。allowUnlisted 属性を false に設定すると、サーバーをロックダウンして、一覧に登録されていないすべての IP アドレスのアクセスを阻止します。この属性を false に設定し、かつ、許可された IP アドレスとしてローカル ループバック アドレス (127.0.0.1) を一覧に登録していない場合、ローカル コンソールからブラウザーを使用してサーバーにアクセスすることはできなくなります。

この属性は、委任にも影響を与えることがあります。親構成でこの属性を false に設定した場合は、<clear> 要素を使用して子構成ファイル内のこの構成を消去することはできません。

既定値は true です。
enableReverseDns オプションの Boolean 属性。

Web サーバーで逆引きドメイン ネーム システム (DNS) 検索を有効にするか無効にするかを指定します。逆引き検索では、IP アドレスが既知の場合にドメイン名の検索を行います。

注意 : 逆引き DNS 検索は、かなりのリソースと時間を使用します。

既定値は false です。

子要素

要素 説明
add オプションの要素。

IP アドレス制限のコレクションに IP 制限を追加します。
remove オプションの要素。

<ipSecurity> コレクションから 1 つの制限に対する参照を削除します。
clear オプションの要素。

<ipSecurity> コレクションから制限に対するすべての参照を削除します。

構成サンプル

次の構成サンプルでは、2 つの IP 制限を Default Web Site に追加します。1 番目の制限では、IP アドレス 192.168.100.1 へのアクセスを拒否し、2 番目の制限では、169.254.0.0 ネットワーク全体へのアクセスを拒否します。

<location path="Default Web Site">
   <system.webServer>

      <security>
         <ipSecurity>
            <add ipAddress="192.168.100.1" />
            <add ipAddress="169.254.0.0" subnetMask="255.255.0.0" />
         </ipSecurity>
      </security>

   </system.webServer>
</location>

サンプル コード

次のコード サンプルでは、2 つの IP 制限を Default Web Site に追加します。1 番目の制限では、IP アドレス 192.168.100.1 へのアクセスを拒否し、2 番目の制限では、169.254.0.0 ネットワーク全体へのアクセスを拒否します。

AppCmd.exe

appcmd.exe set config "Default Web Site" -section:system.webServer/security/ipSecurity /+"[ipAddress='192.168.100.1',allowed='False']" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/security/ipSecurity /+"[ipAddress='169.254.0.0',subnetMask='255.255.0.0',allowed='False']" /commit:apphost

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection ipSecuritySection = config.GetSection("system.webServer/security/ipSecurity", "Default Web Site");
         ConfigurationElementCollection ipSecurityCollection = ipSecuritySection.GetCollection();

         ConfigurationElement addElement = ipSecurityCollection.CreateElement("add");
         addElement["ipAddress"] = @"192.168.100.1";
         addElement["allowed"] = false;
         ipSecurityCollection.Add(addElement);

         ConfigurationElement addElement1 = ipSecurityCollection.CreateElement("add");
         addElement1["ipAddress"] = @"169.254.0.0";
         addElement1["subnetMask"] = @"255.255.0.0";
         addElement1["allowed"] = false;
         ipSecurityCollection.Add(addElement1);

         serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample

   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration
      Dim ipSecuritySection As ConfigurationSection = config.GetSection("system.webServer/security/ipSecurity", "Default Web Site")
      Dim ipSecurityCollection As ConfigurationElementCollection = ipSecuritySection.GetCollection

      Dim addElement As ConfigurationElement = ipSecurityCollection.CreateElement("add")
      addElement("ipAddress") = "192.168.100.1"
      addElement("allowed") = False
      ipSecurityCollection.Add(addElement)

      Dim addElement1 As ConfigurationElement = ipSecurityCollection.CreateElement("add")
      addElement1("ipAddress") = "169.254.0.0"
      addElement1("subnetMask") = "255.255.0.0"
      addElement1("allowed") = False
      ipSecurityCollection.Add(addElement1)

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var ipSecuritySection = adminManager.GetAdminSection("system.webServer/security/ipSecurity", "MACHINE/WEBROOT/APPHOST/Default Web Site");
var ipSecurityCollection = ipSecuritySection.Collection;

var addElement = ipSecurityCollection.CreateNewElement("add");
addElement.Properties.Item("ipAddress").Value = "192.168.100.1";
addElement.Properties.Item("allowed").Value = false;
ipSecurityCollection.AddElement(addElement);

var addElement1 = ipSecurityCollection.CreateNewElement("add");
addElement1.Properties.Item("ipAddress").Value = "169.254.0.0";
addElement1.Properties.Item("subnetMask").Value = "255.255.0.0";
addElement1.Properties.Item("allowed").Value = false;
ipSecurityCollection.AddElement(addElement1);

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set ipSecuritySection = adminManager.GetAdminSection("system.webServer/security/ipSecurity", "MACHINE/WEBROOT/APPHOST/Default Web Site")
Set ipSecurityCollection = ipSecuritySection.Collection

Set addElement = ipSecurityCollection.CreateNewElement("add")
addElement.Properties.Item("ipAddress").Value = "192.168.100.1"
addElement.Properties.Item("allowed").Value = False
ipSecurityCollection.AddElement(addElement)

Set addElement1 = ipSecurityCollection.CreateNewElement("add")
addElement1.Properties.Item("ipAddress").Value = "169.254.0.0"
addElement1.Properties.Item("subnetMask").Value = "255.255.0.0"
addElement1.Properties.Item("allowed").Value = False
ipSecurityCollection.AddElement(addElement1)

adminManager.CommitChanges()