VPN Guide

    Setting Up WireGuard VPN

    WireGuard has become the go-to VPN solution for many users due to its simplicity, speed, and modern cryptography. Combined with RamNode's reliable VPS hosting, you can create your own private VPN server in just a few steps. This guide will walk you through the entire process of setting up WireGuard on a RamNode VPS.

    Ubuntu 22.04/24.04
    WireGuard VPN
    ⏱️ 15-20 minutes

    Prerequisites

    Before starting, ensure you have:

    Server Requirements

    • • RamNode VPS (Ubuntu 22.04/24.04)
    • • Root access to server
    • • SSH client

    Knowledge Requirements

    • • Basic Linux command line
    • • Understanding of networking basics
    • • SSH connection skills
    2

    Initial Server Setup

    Connect to your RamNode VPS and update the system:

    Connect via SSH
    ssh root@your-server-ip
    Update System Packages
    apt update && apt upgrade -y

    💡 Tip: Replace "your-server-ip" with your actual RamNode VPS IP address.

    3

    Install WireGuard

    Install WireGuard and necessary utilities:

    Install WireGuard
    apt install wireguard wireguard-tools -y

    ✅ WireGuard is now installed and ready for configuration.

    4

    Generate Server Keys

    Generate the server's private and public keys:

    Navigate and Generate Keys
    cd /etc/wireguard
    wg genkey | tee server_private.key | wg pubkey > server_public.key
    Set Key Permissions
    chmod 600 server_private.key chmod 644 server_public.key

    🔐 Security: Keep your private key secure and never share it!

    5

    Configure WireGuard Server

    Create the server configuration file:

    Create Config File
    nano /etc/wireguard/wg0.conf

    Add the following configuration (replace SERVER_PRIVATE_KEY with your actual private key):

    WireGuard Server Configuration
    [Interface]
    PrivateKey = SERVER_PRIVATE_KEY
    Address = 10.0.0.1/24
    ListenPort = 51820
    PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
    
    # Client configurations will be added below
    [Peer]
    PublicKey = CLIENT_PUBLIC_KEY
    AllowedIPs = 10.0.0.2/32
    6

    Enable IP Forwarding

    Enable IP forwarding to allow traffic routing:

    Enable IP Forwarding
    echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf
    sysctl -p
    7

    Configure Firewall

    Configure UFW firewall to allow WireGuard traffic:

    Configure UFW Firewall
    ufw allow 51820/udp ufw allow OpenSSH ufw enable

    ⚠️ Warning: Make sure SSH is allowed before enabling UFW to avoid losing access!

    8

    Start WireGuard Service

    Start and enable the WireGuard service:

    Enable and Start Service
    systemctl enable wg-quick@wg0 systemctl start wg-quick@wg0
    Check Service Status
    systemctl status wg-quick@wg0

    🚀 Your WireGuard server is now running!

    9

    Generate Client Configuration

    Generate keys for each client device:

    Generate Client Keys
    wg genkey | tee client_private.key | wg pubkey > client_public.key

    Create a client configuration file:

    Client Configuration File
    [Interface]
    PrivateKey = CLIENT_PRIVATE_KEY
    Address = 10.0.0.2/32
    DNS = 8.8.8.8
    
    [Peer]
    PublicKey = SERVER_PUBLIC_KEY
    Endpoint = YOUR_SERVER_IP:51820
    AllowedIPs = 0.0.0.0/0
    PersistentKeepalive = 25
    10

    Adding Clients to Server

    Add the client's public key to the server:

    Add Client Dynamically
    wg set wg0 peer CLIENT_PUBLIC_KEY allowed-ips 10.0.0.2/32

    Or restart the service after editing the config file:

    Restart Service
    systemctl restart wg-quick@wg0
    11

    Client Setup

    Install WireGuard on your client devices:

    📱 Mobile

    Download WireGuard app from App Store or Google Play

    🖥️ Desktop

    Download from wireguard.com

    🐧 Linux

    Install via package manager

    Linux Client Installation
    apt install wireguard

    📋 Import the client configuration file or manually enter the configuration details in your WireGuard client.

    12

    Testing the Connection

    Follow these steps to test your VPN connection:

    1

    Connect to VPN

    Activate the WireGuard connection on your client device

    2

    Check IP Address

    Check Your IP
    curl ifconfig.me
    3

    Test DNS Resolution

    Test DNS
    nslookup google.com

    ✅ If the IP matches your RamNode VPS IP, your VPN is working correctly!

    Troubleshooting Common Issues

    Security Best Practices

    🔒 Server Security

    • • Regular system updates
    • • Implement fail2ban
    • • Change default SSH port
    • • Monitor server logs

    🗝️ Key Management

    • • Unique keys per client
    • • Secure key storage
    • • Regular key rotation
    • • Revoke unused keys

    🎉 Congratulations!

    You now have a fully functional WireGuard VPN server running on your RamNode VPS. This setup provides secure, encrypted access to the internet through your private server.