搭建自己的 WireGuard VPN
几分钟把 VPS 变成私有 VPN。
安装
apt install wireguard
umask 077
wg genkey | tee server.key | wg pubkey > server.pub服务器配置
创建 /etc/wireguard/wg0.conf:
[Interface]
Address = 10.8.0.1/24
ListenPort = 51820
PrivateKey = <server.key 的内容>
PostUp = sysctl -w net.ipv4.ip_forward=1; iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
[Peer]
PublicKey = <客户端公钥>
AllowedIPs = 10.8.0.2/32将 eth0 替换为您的网卡名(ip a)。
启动
systemctl enable --now wg-quick@wg0
ufw allow 51820/udp客户端
生成客户端密钥对,并创建含 Endpoint = YOUR_IP:51820 与 AllowedIPs = 0.0.0.0/0 的配置,导入 WireGuard 应用。
卡在某一步?
独服与 GPU 客户可提交工单,其他客户可在客户中心使用服务器操作。
支持如何运作 →