Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Tutorial ini menunjukkan kepada Anda cara membuat koneksi VPN AlwaysOn di perangkat klien Windows. Ini melanjutkan seri untuk menyebarkan Always On VPN di lingkungan sampel. Sebelumnya dalam seri ini, Anda menyebarkan infrastruktur sampel dan mengonfigurasi templat Otoritas Sertifikat.
Di tutorial ini, Anda akan:
- Buat dan uji koneksi VPN pengguna manual yang digunakan sebagai templat untuk koneksi VPN AlwaysOn.
- Konversikan koneksi VPN manual ke koneksi VPN AlwaysOn menggunakan PowerShell.
Koneksi VPN AlwaysOn dapat dikonfigurasi sebagai terowongan perangkat atau terowongan pengguna:
Terowongan perangkat: terhubung ke server VPN tertentu sebelum pengguna masuk ke perangkat. Terowongan perangkat digunakan untuk skenario konektivitas sebelum masuk dan tujuan manajemen perangkat.
Terowongan pengguna: hanya tersambung setelah pengguna masuk ke perangkat. Terowongan pengguna memungkinkan pengguna mengakses sumber daya organisasi melalui server VPN.
Untuk informasi selengkapnya tentang perbedaan antara terowongan perangkat dan terowongan pengguna, lihat Mengonfigurasi terowongan perangkat VPN di klien Windows.
Koneksi VPN AlwaysOn, baik terowongan perangkat atau terowongan pengguna, dikonfigurasi menggunakan simpul ProfileXML di penyedia layanan konfigurasi VPNv2 (CSP). Langkah-langkah dalam tutorial ini menunjukkan kepada Anda cara mengonfigurasi terowongan pengguna pada satu perangkat klien Windows. Anda dapat menggunakan langkah-langkah ini untuk lingkungan kecil atau untuk tujuan pengujian.
Untuk lingkungan yang lebih besar, Anda harus menggunakan Microsoft Intune atau Microsoft Configuration Manager untuk menyebarkan profil VPN AlwaysOn ke perangkat klien Windows. Untuk informasi selengkapnya, lihat Menyebarkan profil VPN AlwaysOn ke klien Windows dengan Microsoft Intune dan Menyebarkan profil VPN AlwaysOn ke klien Windows dengan Microsoft Configuration Manager.
Prasyarat
Untuk menyelesaikan langkah-langkah dalam tutorial ini, Anda perlu:
Untuk menyelesaikan semua langkah dalam tutorial sebelumnya:
Perangkat klien Windows dari tutorial sebelumnya dengan sertifikat pengguna yang valid diinstal untuk digunakan untuk menguji koneksi VPN.
Membuat dan menguji koneksi VPN pengguna manual
Pertama, Anda perlu membuat koneksi klien VPN untuk memverifikasi bahwa klien pengujian VPN dapat membuat koneksi VPN yang berhasil. Koneksi ini juga memungkinkan Anda membuat pengaturan Extensible Authentication Protocol (EAP) yang akan digunakan untuk koneksi Vpn AlwaysOn. Untuk informasi selengkapnya tentang pengaturan EAP, lihat Konfigurasi EAP.
Masuk ke perangkat klien Windows yang tergabung dalam domain sebagai pengguna VPN yang Anda buat sebelumnya di Buat pengguna uji Active Directory.
Pada menu Mulai, ketik VPN untuk memilih Pengaturan VPN. Tekan ENTER.
Di panel detail, pilih Tambahkan koneksi VPN.
Untuk Penyedia VPN, pilih Windows (bawaan).
Untuk Nama Koneksi, masukkan CONTOSO VPN.
Untuk Nama atau alamat server, masukkan nama domain eksternal yang sepenuhnya memenuhi syarat (FQDN) server VPN Anda (misalnya,
vpn.contoso.com
).Untuk jenis VPN, pilih IKEv2.
Untuk Jenis info masuk, pilih Sertifikat.
Pilih Simpan.
Di bawah Pengaturan Terkait, pilih Ubah opsi adaptor.
Klik kanan Contoso VPN, dan pilih Properti.
Pada tab Keamanan , untuk Enkripsi data, pilih Enkripsi kekuatan maksimum.
Pilih Gunakan Extensible Authentication Protocol (EAP). Kemudian, untuk Gunakan Extensible Authentication Protocol (EAP), pilih Microsoft: Protected EAP (PEAP) (enkripsi diaktifkan).
Pilih Properti untuk membuka Properti EAP terproteksi, dan selesaikan langkah-langkah berikut:
Untuk Sambungkan ke server ini, masukkan nama host server NPS Anda.
Untuk Otoritas Sertifikasi Akar Tepercaya, pilih CA yang mengeluarkan sertifikat server NPS (misalnya,
contoso-CA
).Untuk Pemberitahuan sebelum menyambungkan, pilih Jangan minta pengguna untuk mengotorisasi server baru atau CA tepercaya.
Untuk Pilih Metode Autentikasi, pilih Kartu Pintar atau sertifikat lainnya.
Pilih Konfigurasikan.
Pilih Gunakan sertifikat pada komputer ini.
Untuk Sambungkan ke server ini, masukkan nama host server NPS.
Untuk Otoritas Sertifikasi Akar Tepercaya, pilih CA yang menerbitkan sertifikat server NPS.
Pilih Jangan minta pengguna untuk mengotorisasi server baru atau otoritas sertifikasi tepercaya.
Pilih OK untuk menutup Kartu Pintar atau Properti Sertifikat lainnya.
Pilih OK untuk menutup Properti EAP terproteksi.
Pilih OK untuk menutup Properti VPN Contoso.
Tutup jendela Koneksi Jaringan .
Di Pengaturan, pilih Contoso VPN, lalu pilih Sambungkan. Koneksi VPN harus berhasil dibuat. Anda dapat memverifikasi koneksi dengan memeriksa jendela Koneksi Jaringan . Koneksi VPN Contoso harus ditampilkan sebagai Tersambung. Uji Anda dapat terhubung ke sumber daya di sisi lain terowongan VPN, misalnya, berbagi file atau server web.
Setelah Anda memverifikasi bahwa koneksi VPN berhasil, putuskan sambungan dari koneksi VPN.
Penting
Pastikan koneksi VPN templat ke server VPN Anda berhasil. Melakukannya memastikan bahwa pengaturan EAP sudah benar sebelum Anda menggunakannya di bagian berikutnya. Anda harus tersambung setidaknya sekali sebelum melanjutkan; jika tidak, profil tidak berisi semua informasi yang diperlukan untuk terhubung ke VPN.
Mengonversi koneksi VPN manual menjadi koneksi VPN AlwaysOn
Selanjutnya, Anda mengonversi koneksi VPN manual ke koneksi VPN AlwaysOn menggunakan skrip PowerShell.
Sebagai pengguna yang sama pada perangkat klien Windows, buka
Windows PowerShell ISE
sebagai Administrator.Salin dan tempel skrip PowerShell berikut ke
Windows PowerShell ISE
jendela editor, lalu pastikan untuk mengubah delapan nilai variabel untuk Anda sendiri.Perluas bagian ini untuk memperlihatkan skrip 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"
Jalankan skrip.
Verifikasi bahwa skrip berhasil dengan menjalankan perintah berikut di
Windows PowerShell ISE
jendela editor:Get-CimInstance -Namespace root\cimv2\mdm\dmmap -ClassName MDM_VPNv2_01
Output harus mirip dengan contoh berikut (
ProfileXML
nilainya dipotong untuk keterbacaan):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 :
Koneksi VPN Always On harus berhasil dibuat dan didirikan. Anda dapat memverifikasi koneksi dengan memeriksa jendela Koneksi Jaringan . Koneksi VPN Contoso Always On harus ditampilkan sebagai Tersambung. Uji Anda dapat terhubung ke sumber daya di sisi lain terowongan VPN, misalnya, berbagi file atau server web.
Konten terkait
Sekarang Anda terhubung ke server VPN menggunakan koneksi Vpn AlwaysOn, berikut adalah beberapa sumber daya tambahan untuk membantu Anda dengan penyebaran Vpn AlwaysOn Anda:
Sebarkan profil VPN AlwaysOn ke klien Windows dengan Microsoft Configuration Manager.
Sebarkan profil VPN AlwaysOn ke klien Windows dengan Microsoft Intune.
Mengonfigurasi akses bersyarah untuk konektivitas VPN menggunakan MICROSOFT Entra ID.
Untuk informasi selengkapnya tentang opsi konfigurasi Always on VPN untuk penyedia layanan konfigurasi (CSP), lihat penyedia layanan konfigurasi VPNv2.
Untuk memecahkan masalah dengan AlwaysOn VPN, lihat Memecahkan Masalah Vpn AlwaysOn.