要将虚拟网卡的 DNS 优先级设置为最高,可以使用以下 PowerShell 脚本:
$nicName = "Virtual NIC" # 虚拟网卡名称
$dnsServers = "192.168.1.1", "8.8.8.8" # DNS 服务器地址
$nic = Get-NetAdapter | Where-Object { $_.InterfaceDescription -eq $nicName }
if ($nic) {
Set-DnsClientServerAddress -InterfaceIndex $nic.ifIndex -ServerAddresses $dnsServers
Set-DnsClient -InterfaceIndex $nic.ifIndex -ConnectionSpecificSuffix "example.com"
}
else {
Write-Host "Virtual NIC not found."
}
请将 $nicName
替换为您的虚拟网卡名称,并将 $dnsServers
替换为您的 DNS 服务器地址列表。如果需要指定连接特定后缀,请将 example.com
替换为您的域名。
运行脚本需要管理员权限,可以在 PowerShell 中右键单击并选择“以管理员身份运行”。