How to Set Up a Secure VPN with WireGuard on Ubuntu Server

Introduction: In the era of remote work and increased concerns for digital privacy, setting up a Virtual Private Network (VPN) has become more crucial than ever. WireGuard is a modern VPN protocol featuring high security and better performance compared to older protocols. This tutorial will guide you through the process of setting up WireGuard on an Ubuntu Server.

Prerequisites: Before starting, ensure you have the following: an Ubuntu Server (20.04 or later) with root access, a basic understanding of Linux commands, and a public IP address for your server.

Step 1: Install WireGuard

Firstly, you need to install WireGuard on your Ubuntu Server. Open your terminal and run the following commands:

sudo apt update
sudo apt install wireguard
These commands update your package list and install WireGuard.

Step 2: Configure WireGuard

After installation, you need to configure the VPN server settings. Start by generating the private and public keys:

cd /etc/wireguard/
umask 077
wg genkey | tee privatekey | wg pubkey > publickey
Note the key outputs as you will need them later.

Create a new configuration file for your VPN server:

nano wg0.conf
In this file, input the following configuration, adjusting the IP addresses as necessary:
[Interface]
PrivateKey = [Your Server's Private Key]
Address = 10.200.200.1/24
ListenPort = 51820
SaveConfig = true

[Peer]
PublicKey = [Your Peer's Public Key]
AllowedIPs = 10.200.200.2/32
Replace "[Your Server's Private Key]" and "[Your Peer's Public Key]" with the appropriate keys you generated earlier.

Step 3: Enable and Start WireGuard

To enable and start the WireGuard service, use the following commands:

sudo systemctl enable [email protected]
sudo systemctl start [email protected]
This sets the WireGuard service to start at boot and runs it immediately.

Conclusion: You now have a basic WireGuard VPN set up on your Ubuntu Server. This setup provides a secure and private tunnel for your internet traffic. For further customization and security, consider adding firewall rules and configuring additional peers.

Note: Always ensure you comply with local laws and regulations when configuring network services like VPNs.

3.

Comments

Popular Posts

Install Ollama and Open WebUI on Ubuntu 24.04 with NVIDIA GPU Acceleration (Step-by-Step)

Install Ollama + Open WebUI on Ubuntu 24.04 with NVIDIA GPU Acceleration (Step-by-Step)

Install a Local AI Chatbot on Ubuntu 24.04 with Ollama and Open WebUI (Step-by-Step)

Trending Now

Recovering from Btrfs Boot Failures Using GUI Tools on Fedora

By the end of this guide the reader will be able to identify a Btrfs‑based Fedora installation, boot from a live USB, list and restore snapshots using the graphical utilities btrfs‑assistant and snapper, and verify that the system returns to a functional state without resorting to the command line. Understanding the Btrfs Layout Used by Fedora Fedora Workstation and Fedora KDE install the root filesystem as a single Btrfs partition that contains two default sub‑volumes. One sub‑volume holds the traditional “/” hierarchy, while the second is dedicated to /var/lib/machines . The latter exists to keep container images out of snapshot operations; it remains empty on systems that do not run virtual machines. Because Btrfs stores data in sub‑volumes rather than separate partitions, a snapshot captures the state of an entire sub‑volume at a point in time. The installer (Anaconda) automatically registers these sub‑volumes with the snapper service. Snapper maintains a series of read‑only ...