我很快将前往一个言论自由法律不那么宽松的国家。
我有一台 Windows 10 机器。我想阻止这台机器通过除 VPN 隧道(有网络端口和 WiFi)之外的所有接口进行通信。如果 VPN 隧道因任何原因关闭,则不允许任何网络流量。即使在 LAN 上也不行。
如果使用 Windows Server 更容易做到这一点,我很乐意切换。
我找到了几篇关于 Windows 防火墙的帖子,并试图遵循这些帖子,但根据我的经验,它并不能捕获所有内容(不过可能是我这边的错误)。
我也有 Windscribe VPN 之类的软件,但是当它的防火墙瘫痪时我设法绕过了它,所以我不信任它,而且它似乎根本没有阻止 DNS 查询(当 Windscribe 阻止时我在 PiHole 中捕获了大量 DNS 查询)
这可以通过一些聪明的电源外壳来实现吗?
谢谢您的帮助!
答案1
实现此目的的最简单方法是使用 Windows 10 上的 LockDown VPN 功能。使用此功能,所有流量只能通过 VPN,不能通过其他接口(建立基本连接以及 VPN 连接所需的流量除外)有关部署此功能的更多信息,请参阅 @https://docs.microsoft.com/en-us/windows/client-management/mdm/vpnv2-csp
此类配置的 VPN 配置文件 XML 示例如下:
<VPNProfile>
<LockDown>true</LockDown>
<RememberCredentials>true</RememberCredentials>
<DnsSuffix>enter.dnsSuffix.forVPNInterface</DnsSuffix>
<NativeProfile>
<Servers>enterserveraddress.com</Servers>
<Authentication>
<UserMethod>Eap</UserMethod>
<MachineMethod>Eap</MachineMethod>
<Eap>
<Configuration>
<EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig"><EapMethod><Type xmlns="http://www.microsoft.com/provisioning/EapCommon">13</Type><VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorId><VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorType><AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId></EapMethod><Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"><Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1"><Type>13</Type><EapType xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1"><CredentialsSource><CertificateStore><SimpleCertSelection>true</SimpleCertSelection></CertificateStore></CredentialsSource><ServerValidation><DisableUserPromptForServerValidation>false</DisableUserPromptForServerValidation><ServerNames></ServerNames></ServerValidation><DifferentUsername>false</DifferentUsername><PerformServerValidation xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV2">false</PerformServerValidation><AcceptServerName xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV2">false</AcceptServerName></EapType></Eap></Config></EapHostConfig>
</Configuration>
</Eap>
</Authentication>
</NativeProfile>
</VPNProfile>
用于提供此 VPN 配置文件 XML 的 Powershell 脚本也如下所示。请注意,要运行此脚本,您需要使用 PSexec 以 System 身份运行 PS 脚本:https://technet.microsoft.com/sysinternals/bb897553.aspx,通过运行 Psexec.exe -i -s cmd.exe
Param(
[string]$xmlFilePath,
[string]$ProfileName
)
$a = Test-Path $xmlFilePath
echo $a
$ProfileXML = Get-Content $xmlFilePath
echo $XML
$ProfileNameEscaped = $ProfileName -replace ' ', '%20'
$Version = 201606090004
$ProfileXML = $ProfileXML -replace '<', '<'
$ProfileXML = $ProfileXML -replace '>', '>'
$ProfileXML = $ProfileXML -replace '"', '"'
$nodeCSPURI = './Vendor/MSFT/VPNv2'
$namespaceName = "root\cimv2\mdm\dmmap"
$className = "MDM_VPNv2_01"
$session = New-CimSession
try
{
$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)
$Message = "Created $ProfileName profile."
Write-Host "$Message"
}
catch [Exception]
{
$Message = "Unable to create $ProfileName profile: $_"
Write-Host "$Message"
exit
}
$Message = "Complete."
Write-Host "$Message"
您可以在 @ 找到有关 Windows 10 VPN 选项的更多信息https://docs.microsoft.com/en-us/windows/access-protection/vpn/vpn-security-features