Introduction: This guide will walk you through setting up WireGuard VPN Server on your Virtual Private Server (VPS) using TurnKey Linux. We'll cover accessing your VPS via SSH, completing the initial TurnKey Linux configuration, setting up the WireGuard server, and configuring clients to connect to your VPN.
Step 1: Access Your VPS via SSH
-
Obtain Your VPS Details:
- IP Address: Provided in your welcome email.
- Root Password: Provided in your welcome email.
- SSH Port: Default is 22 unless specified otherwise.
-
Install an SSH Client:
- Windows: Download PuTTY.
- macOS/Linux: Use the built-in Terminal application.
-
Connect to Your VPS:
- Open your SSH client.
- For Windows (PuTTY):
- Enter your VPS IP in the "Host Name" field.
- Ensure the port is set to 22.
- Click "Open."
- For macOS/Linux Terminal:
<Your-VPS-IP>
with your server's IP address.
Replace
-
Authenticate:
- When prompted, enter the root password.
- Upon successful login, you'll have terminal access to your VPS.
Step 2: Complete TurnKey Linux First Boot Configuration
Upon first login, TurnKey Linux will guide you through initial setup, you can reach this console anytime using command: confconsole
-
Set Root Password:
- You'll be prompted to set a new password for the root user.
-
Configure WireGuard:
- Set the WireGuard VPN server name and private/public keys (these will be generated automatically).
-
Configure Domain and SSL (Optional):
- If you want to access your VPN management interface via a domain, set your domain and configure a Let's Encrypt SSL certificate.
Step 3: Configure WireGuard VPN
-
Access Configuration Files:
- Configuration files are located in
/etc/wireguard/
. - Edit
wg0.conf
to customize your VPN settings.
- Configuration files are located in
-
Enable IP Forwarding:
- Run the following command to enable IP forwarding:
- Make it permanent by editing
/etc/sysctl.conf
and settingnet.ipv4.ip_forward=1
.
-
Start WireGuard:
- Run the following command:
- Enable it to start on boot:
Step 4: Configure WireGuard Clients
-
Generate Client Configuration Files:
- Create configuration files for each client in
/etc/wireguard/clients/
. - Include the server's public key, allowed IPs, and client-specific settings.
- Create configuration files for each client in
-
Install WireGuard Client:
- Install WireGuard on your device:
- Windows: Download from WireGuard Website.
- Linux: Use your package manager:
sudo apt install wireguard
. - Mobile: Install the WireGuard app from your device's app store.
- Install WireGuard on your device:
-
Import Configuration:
- Use the client app to import the generated configuration file and connect.
Step 5: Point Your Domain to Your VPS (Optional)
If you wish to use a domain for WireGuard management, configure it directly via our control panel or your registrar.
Option A: Domain Registered with Us
-
Access Domain Management:
- Log in to your account on our platform.
- Navigate to the "Domain Management" or "DNS Settings" section.
-
Create an A Record:
- Host:
@
(represents the root domain) - Points to: Your VPS IP address
- TTL: Default or 3600 seconds
- Host:
-
Save Changes:
- Apply the new DNS settings.
- Note: DNS changes may take up to 24 hours to propagate.
Option B: Domain Registered Elsewhere
-
Log in to Your Domain Registrar:
- Access the DNS management area.
-
Add an A Record:
- Host:
@
- Points to: Your VPS IP address
- TTL: Default or 3600 seconds
- Host:
-
Save Changes:
- Apply the updated DNS settings.
- Allow time for DNS propagation.
Step 6: Management Tools
Additional Resources:
- TurnKey Linux WireGuard Appliance: TurnKey Linux: WireGuard Appliance
- WireGuard Documentation: WireGuard Official Site
- PuTTY SSH Client: PuTTY Download Page
- Let's Encrypt Documentation: Let's Encrypt Official Site
Note:
- Ensure your VPS firewall allows UDP traffic on WireGuard's port (default 51820).
- DNS changes can take time to propagate globally.
Tips and Troubleshooting
- Connection Issues: Ensure the server and client configurations match.
- Firewall Rules: Verify that UDP traffic on port 51820 is allowed.
- Logs: Check
/var/log/syslog
for WireGuard-related errors.