1.OpenVPN for most commercial VPN providers)

rrdd231535 2026-06-27 科学上网 4 0

Setting up a VPN on Linux can be done in several ways, depending on the type of VPN you want to use (e.g., OpenVPN, WireGuard, or a commercial VPN service). Below are guides for common VPN setups: Most VPN providers (e.g., NordVPN, ExpressVPN, ProtonVPN) offer OpenVPN configuration files.

Install OpenVPN

On Debian/Ubuntu:

sudo apt update
sudo apt install openvpn

On Arch Linux:

sudo pacman -S openvpn

On Fedora/RHEL:

sudo dnf install openvpn

Use VPN Provider Configurations

  1. Download .ovpn config files from your VPN provider.
  2. Place them in /etc/openvpn/:
    sudo cp ~/Downloads/config.ovpn /etc/openvpn/
  3. Start the VPN:
    sudo openvpn --config /etc/openvpn/config.ovpn

    (You may need to enter your VPN username/password.)

Auto-start VPN at Boot

Edit /etc/default/openvpn and enable autostart:

AUTOSTART="all"

Then enable the service:

sudo systemctl enable --now openvpn

WireGuard (Fast & Modern VPN)

WireGuard is lightweight and often faster than OpenVPN.

Install WireGuard

On Debian/Ubuntu:

sudo apt install wireguard resolvconf

On Arch Linux:

sudo pacman -S wireguard-tools

On Fedora/RHEL:

sudo dnf install wireguard-tools

Set Up WireGuard (Client)

  1. Generate keys:

    cd /etc/wireguard/
    sudo umask 077
    sudo wg genkey | tee privatekey | wg pubkey > publickey
  2. Create /etc/wireguard/wg0.conf with your VPN provider's settings:

    [Interface]
    PrivateKey = <your_private_key>
    Address = <assigned_IP>
    DNS = <VPN_DNS>
    [Peer]
    PublicKey = <server_public_key>
    AllowedIPs = 0.0.0.0/0
    Endpoint = <server_IP>:51820
    PersistentKeepalive = 25
  3. Start WireGuard:

    sudo wg-quick up wg0
  4. Enable at boot:

    sudo systemctl enable --now wg-quick@wg0

Using NetworkManager GUI (for some VPNs)

Many VPNs (e.g., ProtonVPN, Mullvad) support NetworkManager integration.

  1. Install the VPN plugin (e.g., for OpenVPN):
    sudo apt install network-manager-openvpn
  2. Go to:
    • Settings > Network > VPN
    • Click and import your VPN config.

Commercial VPN CLI Tools

Some providers offer CLI tools:

  • NordVPN:
    sudo apt install nordvpn
    nordvpn login
    nordvpn connect
  • ProtonVPN:
    sudo apt install protonvpn-cli
    protonvpn-cli login
    protonvpn-cli connect

Check VPN Status

ip a          # Check assigned IP
curl ifconfig.me  # Check public IP
wg show       # WireGuard status

Troubleshooting

  • DNS Leaks: Use dnsleaktest.com to verify.
  • Kill Switch: Block non-VPN traffic with iptables or use your VPN provider's tool.
  • Permissions: Ensure /etc/openvpn/ or /etc/wireguard/ files are readable only by root (chmod 600).

Would you like help with a specific VPN setup? Let me know!

1.OpenVPN for most commercial VPN providers)

扫码下载GOBOY VPN

扫码下载GOBOY VPN

400-83855788
扫码下载GOBOY VPN

扫码下载GOBOY VPN