Install WireGuard VPN on Debian 12

NetCloud24 Knowledge Base Open the video page

Video transcript: NetCloud24 Knowledge Base. Technical guides for a reliable cloud. Clear answers, secure infrastructure, step-by-step guides, cloud and VPS expertise, and 24/7 technical support. Find the answer and keep building.

 

Install WireGuard VPN on Debian 12

Introduction

WireGuard is a modern VPN that is fast, simple, and secure. This guide walks you through the steps of installing WireGuard on Debian 12.

Prerequisites

  • A Debian 12 server
  • Access to the terminal or command line
  • Root privileges or a user with sudo access

Step 1: Update the System

Before installing WireGuard, ensure your system package index is up to date:

sudo apt update
sudo apt upgrade -y

Step 2: Install WireGuard

Install WireGuard using the following command:

sudo apt install wireguard

Step 3: Generate Key Pair

WireGuard uses public and private keys for authentication. Generate a key pair with:

wg genkey | tee privatekey | wg pubkey > publickey

This will create two files: privatekey and publickey in your current directory.

Step 4: Configure WireGuard

Create a configuration file for WireGuard:

sudo nano /etc/wireguard/wg0.conf

Insert the following configuration, replacing YOUR_PRIVATE_KEY and YOUR_SERVER_IP accordingly:

[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = YOUR_PRIVATE_KEY

[Peer]
PublicKey = PEER_PUBLIC_KEY
AllowedIPs = 10.0.0.2/32

Step 5: Enable IP Forwarding

To allow traffic to be forwarded, enable IP forwarding:

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

Step 6: Start the WireGuard Service

To start the WireGuard service, use:

sudo systemctl start wg-quick@wg0

Enable WireGuard on Startup

To enable WireGuard to start on boot, run:

sudo systemctl enable wg-quick@wg0

Step 7: Check the Status

To check if the WireGuard service is running, execute:

sudo systemctl status wg-quick@wg0

Step 8: Configure Firewall (Optional)

If you are using a firewall, make sure to allow the WireGuard port (51820 by default):

sudo ufw allow 51820/udp

Conclusion

You have successfully installed WireGuard VPN on your Debian 12 system. You can now configure clients to connect to your VPN.

Resources

Install WireGuard VPN on Debian 12
Install WireGuard VPN on Debian 12
  • 0 Benutzer fanden dies hilfreich
War diese Antwort hilfreich?

Verwandte Artikel

Boost Your Ubuntu System's Performance with a Swap File: A Step-by-Step Guide

What is a Swap File? A swap file in Ubuntu serves as dedicated virtual memory on your hard...

How to Migrate ISPConfig 2, ISPConfig 3.x, Confixx, CPanel or Plesk to ISPConfig 3.2 (single server)

Introduction Migration from other control panels like ISPConfig 2, ISPConfig 3.x, Confixx,...

How to Install and Configure Zabbix Server and Client on Rocky Linux 9

Introduction Zabbix is an open-source monitoring solution that provides real-time...

How to Install CockroachDB Cluster on Debian 12

Introduction CockroachDB is a distributed SQL database built to handle large-scale,...

How to Install Joomla with Apache and Let's Encrypt SSL on AlmaLinux 9

Introduction Joomla is a popular open-source content management system (CMS) used to build...