WireGuard

1. 使用 wg-quick 命令(最常用)

# 启动名为 wg0 的 WireGuard 接口
sudo wg-quick up wg0

# 停止名为 wg0 的 WireGuard 接口
sudo wg-quick down wg0

这里的 wg0 是配置文件的名称,配置文件通常位于 /etc/wireguard/wg0.conf

2. 使用 systemd 服务(推荐用于开机自启)

# 启用并启动服务(开机自启)
sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0

# 查看服务状态
sudo systemctl status wg-quick@wg0

# 停止服务
sudo systemctl stop wg-quick@wg0

3. 验证连接状态

# 查看 WireGuard 接口状态
wg show

# 查看网络接口
ip a show wg0

# 测试连接
ping 10.0.0.1  # 替换为您的 VPN 服务器地址

4. 常用管理命令

# 查看详细连接信息
wg show wg0

# 实时监控流量
watch -n 1 'wg show wg0 transfer'

安装 WireGuard:

# Ubuntu/Debian
sudo apt install wireguard

# CentOS/RHEL
sudo dnf install wireguard-tools