在 Ubuntu 或 Debian 上安装和自动启动 Wireguard 配置

我们将假设你已经有 wireguard 配置文件,例如 MyVPN.conf

  1. MyVPN.conf 复制到 /etc/wireguard/MyVPN.conf
install_wg.sh
sudo cp MyVPN.conf /etc/wireguard/MyVPN.conf
  1. 启动并启用(即自动启动)服务:
wg_systemctl_enable.sh
sudo systemctl enable --now wg-quick@MyVPN
  1. 使用以下命令检查是否工作
wg_show.sh
sudo wg show

示例 wg-show 输出

wg_show_output.txt
interface: MyVPN
  public key: xJ+A//t9RbOU4ISIr61tsZwc8SPLbLONXhknnU1QvBQ=
  私钥:(隐藏)
  监听端口:12073

peer: xgmml6wPoe9auL5oGhqScQXLByfrI/1xq3sOJzYaNhE=
  端点:77.55.81.22:23711
  允许的 IP:10.178.212.1/32, 10.39.24.0/24
  最新握手:37 秒前
  传输:接收 948 B,发送 1.40 KiB
  持久保活:每 30 秒

Check out similar posts by category: Networking, VPN, Wireguard