Pritunl 安装留档

使用 V2Ray 临时代理,解决网络和库问题

Posted on 2026-02-05 12:34:11   阅读(1) Last updated on 2026-02-05 11:34:45

Ubuntu 24.04(Noble)国内环境

使用 V2Ray 临时代理安装与初始化 Pritunl(可重复执行)

目标

  • 操作系统:Ubuntu 24.04.x LTS(noble)
  • 国内网络环境可稳定执行
  • 使用 V2Ray 客户端作为临时 SOCKS5 代理
  • 成功安装并启动:
    • pritunl
    • mongodb-org
    • openvpn
    • wireguard
  • 初始化后:
    • 每人一个 VPN 配置文件
    • 不启用 OTP / PIN(Google Authenticator)

0. 前置条件

0.1 系统确认

cat /etc/os-release

必须包含: - VERSION_ID=”24.04” - VERSION_CODENAME=noble


1. 安装并配置 V2Ray(临时代理)

1.1 安装 V2Ray

sudo apt update
sudo apt install -y curl unzip ca-certificates
curl -fsSL https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh | sudo bash

验证:

v2ray version

1.2 配置 V2Ray(SOCKS5: 127.0.0.1:1080)

sudo tee /usr/local/etc/v2ray/config.json > /dev/null <<'EOF'
{
  "log": { "loglevel": "warning" },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 1080,
      "protocol": "socks",
      "settings": { "udp": true }
    }
  ],
  "outbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "YOUR_SERVER",
            "port": 443,
            "users": [
              {
                "id": "YOUR_UUID",
                "alterId": 0,
                "security": "auto"
              }
            ]
          }
        ]
      }
    }
  ]
}
EOF

启动:

sudo systemctl enable v2ray
sudo systemctl restart v2ray

验证:

ss -lntp | grep 1080
curl -I --proxy socks5h://127.0.0.1:1080 https://build.openvpn.net

2. 使用 Ubuntu 官方源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak.$(date +%F)

sudo tee /etc/apt/sources.list >/dev/null <<'EOF'
deb http://archive.ubuntu.com/ubuntu noble main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu noble-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu noble-security main restricted universe multiverse
EOF

sudo apt clean
sudo rm -rf /var/lib/apt/lists/*
sudo apt update

3. 添加 Pritunl / MongoDB / OpenVPN 仓库

sudo apt install -y gnupg ca-certificates curl
sudo tee /etc/apt/sources.list.d/mongodb-org.list >/dev/null <<'EOF'
deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse
EOF

sudo tee /etc/apt/sources.list.d/openvpn.list >/dev/null <<'EOF'
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable noble main
EOF

sudo tee /etc/apt/sources.list.d/pritunl.list >/dev/null <<'EOF'
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/stable/apt noble main
EOF

4. 使用 V2Ray 导入 GPG Key

curl -fsSL --proxy socks5h://127.0.0.1:1080 https://www.mongodb.org/static/pgp/server-8.0.asc \
| sudo gpg --dearmor --yes -o /usr/share/keyrings/mongodb-server-8.0.gpg

curl -fsSL --proxy socks5h://127.0.0.1:1080 https://swupdate.openvpn.net/repos/repo-public.gpg \
| sudo gpg --dearmor --yes -o /usr/share/keyrings/openvpn-repo.gpg

curl -fsSL --proxy socks5h://127.0.0.1:1080 https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc \
| sudo gpg --dearmor --yes -o /usr/share/keyrings/pritunl.gpg

5. 安装并启动服务

sudo apt update
sudo apt install -y pritunl mongodb-org openvpn wireguard wireguard-tools
sudo systemctl enable --now mongod pritunl

6. Pritunl 初始化(免 PIN / OTP)

  • Web 管理台:https://服务器IP/
  • Server 设置:
    • Enable Google Authenticator:关闭
  • 每人创建一个用户
  • 每人下载一个配置文件(Profile)

7. 安装完成后

V2Ray 仅用于安装阶段,可关闭:

sudo systemctl stop v2ray

完成

你现在拥有一套 Ubuntu 24.04 国内环境可重复执行的 Pritunl 安装方案