适用于: LifeinCloud Cloud VPS • Ubuntu 22.04 LTS

概览

WireGuard 是一种快速、现代的 VPN 协议,配置简单。虽然 LifeinCloud 提供一键式 WireGuard 镜像,但本指南将介绍如何手动配置。

要求

  • 运行 Ubuntu 22.04 的 LifeinCloud VPS。
  • Root SSH 访问。

步骤 1 — 更新 VPS

ssh root@YOUR_SERVER_IP
apt update && apt upgrade -y

步骤 2 — 安装 WireGuard

apt install -y wireguard qrencode

步骤 3 — 生成密钥

umask 077
wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey

步骤 4 — 创建配置文件

nano /etc/wireguard/wg0.conf
[Interface]
Address = 10.0.0.1/24
PrivateKey = (/etc/wireguard/privatekey 的内容)
ListenPort = 51820
SaveConfig = true

[Peer]
PublicKey = CLIENT_PUBLIC_KEY
AllowedIPs = 10.0.0.2/32

步骤 5 — 启用并启动 WireGuard

systemctl enable wg-quick@wg0
systemctl start wg-quick@wg0

步骤 6 — 防火墙规则

ufw allow 51820/udp
注意: 为避免手动设置,可以直接从 LifeinCloud 控制面板部署一键 WireGuard VPN 镜像
這篇文章有幫助嗎? 0 用戶發現這個有用 (0 投票)