Debian 安装WireGuard
Linux 默认分类 107

在 Debian 上安装 WireGuard 可以通过以下步骤完成:

  1. 更新系统包索引:
    首先,确保你的包管理器是最新的。打开终端并运行以下命令:

    sudo apt update
    
  2. 安装 WireGuard:
    在 Debian 10 及更高版本中,WireGuard 已经包含在默认的包库中。你可以直接安装:

    sudo apt install wireguard
    

    如果你使用的是更早版本的 Debian,可能需要添加 backports 仓库来安装 WireGuard。

  3. 生成密钥对:
    WireGuard 使用公钥和私钥进行加密通信。你需要为每个节点生成一对密钥。运行以下命令生成密钥对:

    wg genkey | tee privatekey | wg pubkey > publickey
    

    这会在当前目录下生成 privatekey 和 publickey 文件。

  4. 配置 WireGuard:
    创建一个新的配置文件,例如 /etc/wireguard/wg0.conf。这是一个简单的配置文件示例:

    [Interface]
    PrivateKey = <你的私钥>
    Address = 10.0.0.1/24
    ListenPort = 51820
    
    [Peer]
    PublicKey = <对等方的公钥>
    AllowedIPs = 10.0.0.2/32
    Endpoint = <对等方的IP>:51820
    

    请根据你的网络配置修改 <你的私钥>、<对等方的公钥> 和 <对等方的IP>。

  5. 启用并启动 WireGuard:
    使用以下命令启用并启动 WireGuard 接口:

    sudo wg-quick up wg0
    

    如果你想在系统启动时自动启动 WireGuard,可以使用:

    sudo systemctl enable wg-quick@wg0
    
  6. 检查 WireGuard 状态:
    你可以使用以下命令查看 WireGuard 的状态:

    sudo wg
    

这样,你就应该能够在 Debian 上成功安装和配置 WireGuard 了。如果有任何问题,请确保检查日志文件和配置文件的正确性。

Debian 安装WireGuard
https://930123.xyz/archives/debian-an-zhuang-wireguard
作者
Administrator
发布于
更新于
许可