このチュートリアルでは、Windows クライアント デバイスで Always On VPN 接続を作成する方法について説明します。 このシリーズは、サンプル環境で Always On VPN をデプロイし続けます。 以前のシリーズでは、 サンプル インフラストラクチャをデプロイ し、 証明機関テンプレートを構成しました。
このチュートリアルでは、次の操作を行います。
- Always On VPN 接続のテンプレートとして使用される手動ユーザー VPN 接続を作成してテストします。
- PowerShell を使用して、手動 VPN 接続を Always On VPN 接続に変換します。
Always On VPN 接続は、デバイス トンネルまたはユーザー トンネルとして構成できます。
デバイス トンネル: ユーザーがデバイスにサインインする前に、指定された VPN サーバーに接続します。 デバイス トンネルは、ログイン前の接続シナリオとデバイス管理の目的で使用されます。
ユーザー トンネル: ユーザーがデバイスにログオンした後にのみ接続します。 ユーザー トンネルを使用すると、ユーザーは VPN サーバーを介して組織のリソースにアクセスできます。
デバイス トンネルとユーザー トンネルの違いの詳細については、「 Windows クライアントでの VPN デバイス トンネルの構成」を参照してください。
Always On VPN 接続は、デバイス トンネルでもユーザー トンネルでも、VPNv2 構成サービス プロバイダー (CSP) の ProfileXML ノードを使用して構成されます。 このチュートリアルの手順では、単一の Windows クライアント デバイスでユーザー トンネルを構成する方法について説明します。 これらの手順は、小規模な環境やテスト目的で使用できます。
大規模な環境では、Microsoft Intune または Microsoft Configuration Manager を使用して、Always On VPN プロファイルを Windows クライアント デバイスに展開する必要があります。 詳細については、「 Microsoft Intune を使用して Always On VPN プロファイルを Windows クライアントに展開する」および「MicrosoftConfiguration Manager を使用して Always On VPN プロファイルを Windows クライアントに展開する」を参照してください。
前提条件
このチュートリアルを完了するには、以下が必要になります。
前のチュートリアルのすべての手順を完了するには:
VPN 接続のテストに使用する有効なユーザー証明書がインストールされた、前のチュートリアルの Windows クライアント デバイス。
手動ユーザー VPN 接続を作成してテストする
まず、VPN テスト クライアントが正常な VPN 接続を確立できることを確認するために、VPN クライアント接続を作成する必要があります。 この接続により、Always On VPN 接続に使用する拡張認証プロトコル (EAP) 設定を作成することもできます。 EAP 設定の詳細については、「EAP の構成」を参照してください。
ドメインに参加している Windows クライアント デバイスに、前に Active Directory テスト ユーザーの作成で作成した VPN ユーザーとしてサインインします。
[スタート] メニューで、「VPN」と入力して [VPN の設定] を選択します。 ENTER キーを押します。
詳細ペインで、[VPN 接続を追加する] をクリックします。
[VPN プロバイダー] で、[Windows (ビルトイン)] を選択します。
[接続名] に「Contoso VPN」と入力します。
[サーバー名またはアドレス] に、VPN サーバーの外部完全修飾ドメイン名 (FQDN) を入力します (例:
vpn.contoso.com
)。[VPN の種類] で [IKEv2] を選択します。
[サインイン情報の種類] で [証明書] を選択します。
[保存] を選択します。
[ 関連設定] で、[ アダプター オプションの変更] を選択します。
Contoso VPN を右クリックし、プロパティ を選択します。
[セキュリティ] タブの [データの暗号化] で、[最強の暗号化] を選択します。
[Use Extensible Authentication Protocol (EAP)] (拡張認証プロトコルを使う (EAP)) を選択します。 次に、[Use Extensible Authentication Protocol (EAP)] (拡張認証プロトコルを使う (EAP)) で、[Microsoft: Protected EAP (PEAP) (encryption enabled)] (Microsoft:保護された EAP (PEAP) (暗号化が有効)) を選択します。
[プロパティ] を選択して保護された EAP プロパティを開き、次の手順を実行します。
[これらのサーバーに接続する] に、NPS サーバーのホスト名を入力します。
信頼されたルート証明機関の場合は、NPS サーバーの証明書を発行した CA (たとえば、
contoso-CA
) を選択します。[接続前の通知] で、[新しいサーバーまたは信頼された CA を承認するときにユーザーに確認を求めません] を選択します。
[認証方法を選択する] で、[スマート カードまたはその他の証明書] を選択します。
[構成] をクリックします。
[このコンピューターの証明書を使う] を選択します。
[これらのサーバーに接続する] に、NPS サーバーのホスト名を入力します。
[信頼されたルート証明機関] で、NPS サーバーの証明書を発行したルート CA を選択します。
[新しいサーバーまたは信頼された証明機関を承認するようユーザーに求めない] をオンにします。
[ OK] を 選択して 、スマート カードまたはその他の証明書のプロパティを閉じます。
[ OK] を 選択して 保護された EAP プロパティを閉じます。
[ OK] を 選択して Contoso VPN のプロパティを閉じます。
[ネットワーク接続] ウィンドウを閉じます。
[設定] で [Contoso VPN] を選択し、[接続] を選択します。 VPN 接続が正常に確立されている必要があります。 接続を確認するには、[ ネットワーク接続 ] ウィンドウを確認します。 Contoso VPN 接続は [接続済み] と表示されます。 テストでは、VPN トンネルの反対側のリソース (ファイル共有や Web サーバーなど) に接続できます。
VPN 接続が成功したことを確認したら、VPN 接続から切断します。
重要
VPN サーバーへのテンプレート VPN 接続が正常に行われていることを確認します。 そうすることで、次のセクションで使用する前に EAP 設定が正しいことを確認できます。 続行する前に少なくとも 1 回接続する必要があります。それ以外の場合、プロファイルには VPN への接続に必要なすべての情報が含まれているわけではありません。
手動 VPN 接続を Always On VPN 接続に変換する
次に、PowerShell スクリプトを使用して、手動 VPN 接続を Always On VPN 接続に変換します。
Windows クライアント デバイス上の同じユーザーとして、管理者として
Windows PowerShell ISE
を開きます。次の PowerShell スクリプトをコピーして
Windows PowerShell ISE
エディター ウィンドウに貼り付け、必ず独自の 8 つの変数値を変更してください。PowerShell スクリプトを表示するには、このセクションを展開します。
# Set the variables for the VPN profile. $___domain = 'corp' # Name of the ___domain. $templateName = 'Contoso VPN' # Name of the test VPN connection you created in the tutorial. $profileName = 'Contoso AlwaysOn VPN' # Name of the profile we are going to create. $servers = 'aov-vpn.contoso.com' # Public or routable IP address or DNS name for the VPN gateway. $dnsSuffix = 'corp.contoso.com' # Specifies one or more commas separated DNS suffixes. $domainName = '.corp.contoso.com' # Used to indicate the namespace to which the policy applies. Contains `.` prefix. $dnsServers = '10.10.0.6' # List of comma-separated DNS Server IP addresses to use for the namespace. $trustedNetwork = 'corp.contoso.com' # Comma-separated string to identify the trusted network. # Get the EAP settings for the current profile called $templateName $connection = Get-VpnConnection -Name $templateName if(!$connection) { $message = "Unable to get $templateName connection profile: $_" Write-Host "$message" exit } $EAPSettings= $connection.EapConfigXmlStream.InnerXml $profileNameEscaped = $profileName -replace ' ', '%20' # Define ProfileXML $profileXML = @(" <VPNProfile> <DnsSuffix>$dnsSuffix</DnsSuffix> <NativeProfile> <Servers>$servers</Servers> <NativeProtocolType>IKEv2</NativeProtocolType> <Authentication> <UserMethod>Eap</UserMethod> <Eap> <Configuration> $EAPSettings </Configuration> </Eap> </Authentication> <RoutingPolicyType>SplitTunnel</RoutingPolicyType> </NativeProfile> <AlwaysOn>true</AlwaysOn> <RememberCredentials>true</RememberCredentials> <TrustedNetworkDetection>$trustedNetwork</TrustedNetworkDetection> <DomainNameInformation> <DomainName>$domainName</DomainName> <DnsServers>$dnsServers</DnsServers> </DomainNameInformation> </VPNProfile> ") # Output the XML for possible use in Intune $profileXML | Out-File -FilePath ($env:USERPROFILE + '\desktop\VPN_Profile.xml') # Escape special characters in the profile (<,>,") $profileXML = $profileXML -replace '<', '<' $profileXML = $profileXML -replace '>', '>' $profileXML = $profileXML -replace '"', '"' # Define WMI-to-CSP Bridge properties $nodeCSPURI = "./Vendor/MSFT/VPNv2" $namespaceName = "root\cimv2\mdm\dmmap" $className = "MDM_VPNv2_01" try { # Determine user SID for VPN profile. $WmiLoggedOnUsers = (Get-WmiObject Win32_LoggedOnUser).Antecedent If($WmiLoggedOnUsers.Count -gt 1) { $WmiLoggedOnUsers = $WmiLoggedOnUsers -match "Domain=""$___domain""" } $WmiUserValid = ($WmiLoggedOnUsers | Select-Object -Unique -First 1) -match 'Domain="([^"]+)",Name="([^"]+)"' If(-not $WmiUserValid){ Throw "Returned object is not a valid WMI string" } $UserName = "$($Matches[1])\$($Matches[2])" $ObjUser = New-Object System.Security.Principal.NTAccount($UserName) $Sid = $ObjUser.Translate([System.Security.Principal.SecurityIdentifier]) $SidValue = $Sid.Value $message = "User SID is $SidValue." Write-Host "$message" } catch [Exception] { $message = "Unable to get user SID. $_" Write-Host "$message" exit } try { # Define WMI session. $session = New-CimSession $options = New-Object Microsoft.Management.Infrastructure.Options.CimOperationOptions $options.SetCustomOption("PolicyPlatformContext_PrincipalContext_Type", "PolicyPlatform_UserContext", $false) $options.SetCustomOption("PolicyPlatformContext_PrincipalContext_Id", "$SidValue", $false) } catch { $message = "Unable to create new session for $profileName profile: $_" Write-Host $message exit } try { # Detect and delete previous VPN profile. $deleteInstances = $session.EnumerateInstances($namespaceName, $className, $options) foreach ($deleteInstance in $deleteInstances) { $InstanceId = $deleteInstance.InstanceID if ("$InstanceId" -eq "$profileNameEscaped") { $session.DeleteInstance($namespaceName, $deleteInstance, $options) $message = "Removed $profileName profile $InstanceId" Write-Host "$message" } else { $message = "Ignoring existing VPN profile $InstanceId" Write-Host "$message" } } } catch [Exception] { $message = "Unable to remove existing outdated instance(s) of $profileName profile: $_" Write-Host $message exit } try { # Create the VPN profile. $newInstance = New-Object Microsoft.Management.Infrastructure.CimInstance $className, $namespaceName $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("ParentID", "$nodeCSPURI", "String", "Key") $newInstance.CimInstanceProperties.Add($property) $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("InstanceID", "$profileNameEscaped", "String", "Key") $newInstance.CimInstanceProperties.Add($property) $property = [Microsoft.Management.Infrastructure.CimProperty]::Create("ProfileXML", "$profileXML", "String", "Property") $newInstance.CimInstanceProperties.Add($property) $session.CreateInstance($namespaceName, $newInstance, $options) $message = "Created $profileName profile." Write-Host "$message" } catch [Exception] { $message = "Unable to create $profileName profile: $_" Write-Host "$message" exit } $message = "Always On VPN connection created successfully." Write-Host "$message"
スクリプトを実行します。
Windows PowerShell ISE
エディター ウィンドウで次のコマンドを実行して、スクリプトが成功したことを確認します。Get-CimInstance -Namespace root\cimv2\mdm\dmmap -ClassName MDM_VPNv2_01
出力は次の例のようになります (読みやすくするために
ProfileXML
値が切り捨てられます)。AlwaysOn : True ByPassForLocal : DeviceTunnel : DnsSuffix : corp.contoso.com EdpModeId : InstanceID : Contoso%20AlwaysOn%20VPN LockDown : ParentID : ./Vendor/MSFT/VPNv2 ProfileXML : <VPNProfile>...</VPNProfile> RegisterDNS : RememberCredentials : True TrustedNetworkDetection : corp.contoso.com PSComputerName :
Always On VPN 接続を正常に作成して確立する必要があります。 接続を確認するには、[ ネットワーク接続 ] ウィンドウを確認します。 Contoso Always On VPN 接続は [接続済み] と表示されます。 テストでは、VPN トンネルの反対側のリソース (ファイル共有や Web サーバーなど) に接続できます。
関連コンテンツ
Always On VPN 接続を使用して VPN サーバーに接続します。Always On VPN の展開に役立つ追加のリソースを次に示します。
Microsoft Configuration Manager を使用して、Always On VPN プロファイルを Windows クライアントに展開します。
Microsoft Intune を使用して、Always On VPN プロファイルを Windows クライアントに展開します。
構成サービス プロバイダー (CSP) の Always on VPN 構成オプションの詳細については、VPNv2 構成サービス プロバイダーに関するページを参照してください。
Always On VPN に関する問題のトラブルシューティングについては、「Always On VPN のトラブルシューティング」を参照してください。