前往 WireGuard 官网下载
访问 WireGuard 官网,找到适合你的 Windows 版本的预编译安装文件。
安装 WireGuard
- 下载并双击运行安装文件:下载完成后,双击
wireguard-install.exe开始安装。 - 按照提示完成安装:安装程序会引导你选择安装路径和是否创建桌面快捷符,完成后点击“完成”按钮。
安装完成后配置 WireGuard
- 打开 PowerShell 或 Windows 终端:以管理员身份运行 PowerShell,以便进行接口管理。
- 创建新的 WireGuard 接口:
New-NetInterface -Name "WGInterface" -Description "WireGuard Interface" -IPv4AddressType Static -IPv4Address 192.168.1.1/24
这里,
168.1.1/24是你选择的子网。 - 设置路由表:
Set-NetRoute -Interface "WGInterface" -DestinationPrefix 0.../ -NextHop 10.10.10.1 -Metric 1
这里,
10.10.1是你的互联网接口地址。
连接到 WireGuard 服务器
- 查看可靠服务器列表:访问 Cloudflare 的 WireGuard 服务器列表,选择一个靠近你的服务器。
- 使用以下命令连接:
Add-NetRoute -Interface "WGInterface" -DestinationPrefix 0.../ -NextHop 2001:db8::1 -Metric 1
这里,
2001:db8::1是 Cloudflare 提供的一个示例服务器地址。
测试连接
- ping 测试:
ping 8.8.8.8
如果你能成功 ping 到互联网服务器,说明连接成功。
安全设置(可选)
- 设置接口密钥:
Set-NetInterface -Name "WGInterface" -PrivateKey (ConvertTo-SecureString "your-private-key" -AsBytes)
替换
your-private-key为你的私钥。
管理接口(可选)
- 创建新接口:
wg-clone WGInterface
- 删除旧接口:
Remove-NetInterface -Name "Old-WGInterface"
卸载 WireGuard(如果需要)
使用以下命令移除安装的文件:
Remove-Program "WireGuard"
通过以上步骤,你应该能够顺利安装并配置 WireGuard,确保网络连接安全且高效。









