WireGuard Windows 服务器多客户端互通完整部署步骤

WireGuard Windows 服务器多客户端互通完整部署步骤

1. 环境规划

服务器系统:Windows

VPN 网段:10.0.0.0/24

服务器 VPN 地址:10.0.0.1

监听端口:8784

客户端 1(Windows):10.0.0.2

客户端 2(手机):10.0.0.3

2. 安装 WireGuard

下载并安装 WireGuard for Windows

打开软件,新建空隧道,自动生成密钥

3. 开启系统 IP 转发(必须)

以管理员身份运行 CMD,执行:

bash 复制代码
reg add "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v IPEnableRouter /t REG_DWORD /d 1 /f

执行完成后重启 Windows 服务器

4. 服务器配置文件 wg0.conf

bash 复制代码
[Interface]
PrivateKey = 服务器私钥
ListenPort = 8784
Address = 10.0.0.1/24
PostUp = route add 10.0.0.0 mask 255.255.255.0 10.0.0.1
PostDown = route delete 10.0.0.0 mask 255.255.255.0 10.0.0.1
[Peer]
PublicKey = 客户端1公钥
AllowedIPs = 10.0.0.2/32
[Peer]
PublicKey = 客户端2公钥
AllowedIPs = 10.0.0.3/32

5. 客户端 1 配置(Windows 10.0.0.2)

bash 复制代码
[Interface]
PrivateKey = 客户端1私钥
Address = 10.0.0.2/24
DNS = 10.0.0.1, 8.8.8.8
MTU = 1420
[Peer]
PublicKey = 服务器公钥
AllowedIPs = 10.0.0.0/24
Endpoint = 101.223.183.11:8784 # 服务器地址
PersistentKeepalive = 25

6. 客户端 2 配置(手机 10.0.0.3)

bash 复制代码
[Interface]
PrivateKey = 客户端2私钥
Address = 10.0.0.3/24
DNS = 10.0.0.1, 8.8.8.8
MTU = 1420
[Peer]
PublicKey =  服务器公钥
AllowedIPs = 10.0.0.0/24
Endpoint = 101.223.183.11:8784 # 服务器地址
PersistentKeepalive = 25

7. Windows 客户端防火墙放行

管理员 CMD 执行:

bash 复制代码
netsh advfirewall firewall add rule name="Allow WireGuard LAN" dir=in action=allow remoteip=10.0.0.0/24 profile=any enable=yes

放行 8788 端口:

bash 复制代码
netsh advfirewall firewall add rule name="Allow VPN 8788" dir=in action=allow protocol=TCP localport=8788 remoteip=10.0.0.0/24 profile=any enable=yes

8. 检查服务监听端口

CMD 执行:

bash 复制代码
netstat -ano | findstr ":8788"

必须显示 0.0.0.0:8788 才能被外部访问

9. 连通性验证

服务器 ping 10.0.0.2

服务器 ping 10.0.0.3

客户端 1 ping 10.0.0.3

手机 ping 10.0.0.2

手机访问 http://10.0.0.2:8788

10. 关键要点总结

Windows 必须开启 IP 转发并重启

服务器必须配置 PostUp/PostDown 路由

每个客户端单独 [Peer],AllowedIPs 使用 /32

Windows 客户端必须放通 10.0.0.0/24 网段

服务必须监听 0.0.0.0 才能被跨设备访问

相关推荐
安科士andxe7 小时前
深入解析|安科士1.25G CWDM SFP光模块核心技术,破解中长距离传输痛点
服务器·网络·5g
2601_9491465310 小时前
Shell语音通知接口使用指南:运维自动化中的语音告警集成方案
运维·自动化
儒雅的晴天10 小时前
大模型幻觉问题
运维·服务器
Gofarlic_OMS11 小时前
科学计算领域MATLAB许可证管理工具对比推荐
运维·开发语言·算法·matlab·自动化
通信大师11 小时前
深度解析PCC策略计费控制:核心网产品与应用价值
运维·服务器·网络·5g
dixiuapp11 小时前
智能工单系统如何选,实现自动化与预测性维护
运维·自动化
Elastic 中国社区官方博客11 小时前
如何防御你的 RAG 系统免受上下文投毒攻击
大数据·运维·人工智能·elasticsearch·搜索引擎·ai·全文检索
小锋学长生活大爆炸11 小时前
【教程】免Root在Termux上安装Docker
运维·docker·容器
进击切图仔11 小时前
常用 Docker 命令备份
运维·docker·容器
NotStrandedYet12 小时前
《国产系统运维笔记》第8期:挑战国产化流媒体部署——银河麒麟+龙芯架构编译SRS实战全记录
运维·kylin·国产化·银河麒麟·龙芯·信创运维·srs编译安装