How to Install WireGuard VPN on Ubuntu 24.04 (Step-by-Step Guide)

WireGuard is built directly into the Linux kernel starting from version 5.6 and above, which includes Ubuntu 24.04. That means installing and using WireGuard is easier and more efficient than ever.

Jun 14, 2025 - 19:44
 0

If you're looking for a fast, modern, and secure VPN protocol, WireGuard is a top contender. It's lightweight, simple to configure, and offers excellent encryption. In this guide, we will walk you through how to install WireGuard VPN on Ubuntu 24.04, ensuring your internet traffic is secure and encrypted.

WireGuard is built directly into the Linux kernel starting from version 5.6 and above, which includes Ubuntu 24.04. That means installing and using WireGuard is easier and more efficient than ever.


Why Choose WireGuard VPN?

WireGuard is a revolutionary VPN protocol designed to be faster and simpler than older protocols like OpenVPN and IPsec. Some of its key benefits include:

  • High-speed performance

  • Simple codebase (~4,000 lines)

  • Modern encryption standards (ChaCha20, Curve25519)

  • Kernel-level integration on Linux

Whether you're securing your personal browsing or creating a private network between remote systems, installing WireGuard VPN on Ubuntu 24.04 is a smart solution.


Step 1: Update Your System

Before you start the installation, ensure your system is updated to avoid compatibility issues.

bash
sudo apt update && sudo apt upgrade -y

Step 2: Install WireGuard VPN on Ubuntu 24.04

The easiest way to install WireGuard on Ubuntu 24.04 is using APT. Since it's included in the official Ubuntu repositories, you can run:

bash
sudo apt install wireguard -y

This command installs the necessary WireGuard tools and kernel module.


Step 3: Generate Private and Public Keys

Next, generate a private and public key pair. This is essential for authenticating peers.

bash
wg genkey | tee privatekey | wg pubkey > publickey

These keys will be saved in the current directory. Use strong permissions:

bash
chmod 600 privatekey

Step 4: Create WireGuard Configuration File

Create a configuration file for the WireGuard interface. The default file location is:

bash
sudo nano /etc/wireguard/wg0.conf

Here’s a basic example of what to include in your wg0.conf:

ini
[Interface] PrivateKey = <YourPrivateKey> Address = 10.0.0.1/24 ListenPort = 51820 [Peer] PublicKey = <PeerPublicKey> AllowedIPs = 10.0.0.2/32 Endpoint = <PeerIP>:51820

Replace <YourPrivateKey>, <PeerPublicKey>, and <PeerIP> with actual values.


Step 5: Enable IP Forwarding (If acting as a VPN server)

If your WireGuard node will route traffic, enable IP forwarding:

bash
sudo sysctl -w net.ipv4.ip_forward=1

To make this persistent:

bash
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf sudo sysctl -p

Step 6: Start and Enable WireGuard VPN

Now that everything is configured, start the WireGuard VPN service:

bash
sudo wg-quick up wg0

To enable it on boot:

bash
sudo systemctl enable wg-quick@wg0

To check status:

bash
sudo wg

Step 7: Firewall Configuration (Optional)

Allow traffic on WireGuard’s default port (51820) using UFW:

bash
sudo ufw allow 51820/udp

If you’re using another firewall, open the same UDP port accordingly.


Step 8: Connect Your Peer(s)

To connect a second device (peer), install WireGuard and use a mirrored configuration with the relevant keys and IP addresses. You should define one peer per device for clarity and security.


Step 9: Troubleshooting Tips

If you face issues during installation or setup, consider:

  • Checking firewall rules

  • Ensuring ports are correctly open

  • Verifying public/private keys

  • Reviewing logs:

    bash
    sudo journalctl -xe 

Final Words

Congratulations! You’ve successfully installed WireGuard VPN on Ubuntu 24.04. Whether you want to secure your own internet browsing, access remote systems, or build a private mesh network, WireGuard is a powerful, efficient tool.

By completing these steps, you now have a reliable VPN solution that offers cutting-edge security and performance. Remember to keep your private keys secure and backup your wg0.conf file for future reference.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0