WireGuard VPN Server mit Web Interface einrichten - adminForge (2024)

Wer aktuell OpenVPN und IPsec als VPN Software einsetzt und sich schon immer mal mit WireGuard auseinander setzen wollte, dem helfe ich mit diesem Tutorial auf die Sprünge.

WireGuard ist eine freie Software zum Aufbau eines virtuellen privaten Netzwerkes (VPN) über eine verschlüsselte Verbindung.

WireGuard ist im Aufbau wesentlich einfacher gestaltet als beispielsweise OpenVPN und verwendet nur ein eingeschränktes Set an Algorithmen. So wird unter anderem für den Schlüsselaustausch das Verfahren Curve25519 und für die eigentliche Verschlüsselung ChaCha20 verwendet.

Vorteile von WireGuard zusammengefasst:

  • schneller, auch auf älteren und schwächeren Systemen
  • sicherer, dank neuster Verschlüsselungstechnologie
  • wirklich einfach einzurichten dank wireguard-ui

Was wird für dieses Tutorial benötigt?

Ziel in diesem Tutorial?

  • Ein VPN Netzwerk mit Server und Client innerhalb weniger Minuten einrichten
  • Ein Web Interface zur einfachen Einrichtung von Server und Clients
  • Mobile Clients einfach per QR Code einrichten

Punkt 1: Debian Pakete installieren

Quelle: https://www.wireguard.com/install/

Wir installieren alle nötigen Pakete und wechseln den Ordner.

1

2

apt update && apt install -y wireguard curl tar

cd /etc/wireguard

Punkt 2: Firewall Port öffnen

Der Port 51820 für das UDP Protokoll muss auf dem Server erreichbar sein. Beispielsweise so zu öffnen:

1

ufw allow 51820/udp

Punkt 3: IP Forwarding aktivieren

Das IP Forwarding sorgt dafür, dass alle Pakete der WireGuard-Schnittstelle weitergeleitet werden.

Punkt 4: WireGuard UI Startscript erstellen

Dieses Startscript wird von der Systemd Service Unit (Punkt 5) verwendet um WureGuard UI zu staren und die Datenbank im Ordner /etc/wireguard/db/ abzulegen.

1

2

3

4

5

6

cat <<EOF > /etc/wireguard/start-wgui.sh

#!/bin/bash

cd /etc/wireguard

./wireguard-ui -bind-address 0.0.0.0:5000

EOF

ACHTUNG: Die -bind-address 0.0.0.0:5000 sollte aus Sicherheitsgründen, sobald der erste Tunnel steht, gegen die WireGuard Server IP-Adresse 10.252.1.0 ausgetauscht werden!

Wir machen das Script ausführbar.

1

chmod +x start-wgui.sh

Punkt 5: WireGuard UI

Quelle: https://github.com/ngoduykhanh/wireguard-ui

Zuerst legen wir die Systemd Service Unit an.

1

2

3

4

5

6

7

8

9

10

11

cat <<EOF > /etc/systemd/system/wgui-web.service

[Unit]

Description=WireGuard UI

[Service]

Type=simple

ExecStart=/etc/wireguard/start-wgui.sh

[Install]

WantedBy=multi-user.target

EOF

Nun legen wir das WireGuard UI Download und Update Script an.

1

2

3

4

5

6

7

8

9

10

11

12

13

cat <<EOF > /etc/wireguard/update.sh

#!/bin/bash

VER=\$(curl -sI https://github.com/ngoduykhanh/wireguard-ui/releases/latest | grep "location:" | cut -d "/" -f8 | tr -d '\r')

echo "downloading wireguard-ui \$VER"

curl -sL "https://github.com/ngoduykhanh/wireguard-ui/releases/download/\$VER/wireguard-ui-\$VER-linux-amd64.tar.gz" -o wireguard-ui-\$VER-linux-amd64.tar.gz

echo -n "extracting "; tar xvf wireguard-ui-\$VER-linux-amd64.tar.gz

echo "restarting wgui-web.service"

systemctl restart wgui-web.service

EOF

Jetzt können wir das WireGuard UI Update Script das erste Mal ausführen. Der Download startet automatisch und das Web Interface von WireGuard wird gestartet.

1

2

chmod +x /etc/wireguard/update.sh

cd /etc/wireguard; ./update.sh

Punkt 6: WireGuard Konfigurationsdatei von Systemd überwachen lassen

Die folgenden beiden Systemd Units erstellen wir um die WireGuard Konfiguration wg0.conf zu überwachen und den Service automatisch bei Änderung neustarten zu lassen.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

cat <<EOF > /etc/systemd/system/wgui.service

[Unit]

Description=Restart WireGuard

After=network.target

[Service]

Type=oneshot

ExecStart=/bin/systemctl restart wg-quick@wg0.service

[Install]

RequiredBy=wgui.path

EOF

cat <<EOF > /etc/systemd/system/wgui.path

[Unit]

Description=Watch /etc/wireguard/wg0.conf for changes

[Path]

PathModified=/etc/wireguard/wg0.conf

[Install]

WantedBy=multi-user.target

EOF

Punkt 7: Dienste aktivieren und starten

1

2

3

touch /etc/wireguard/wg0.conf

systemctl enable wgui.{path,service} wg-quick@wg0.service wgui-web.service

systemctl start wgui.{path,service}

Punkt 8: WireGuard UI öffnen und einstellen

  1. Das WireGuard UI öffnen wir nun im Webbrowser: http://<PUBLIC IP>:5000
  2. Melden uns als Benutzer admin und dem Passwort admin an
  3. Klicken links im Menü auf Global Settings
  4. Wir prüfen zuerst ob die Endpoint Address stimmt (kann eine Public IP oder Hostname sein)
  5. Nun löschen wir 1.1.1.1 unter DNS Servers
  6. Fügen diese beiden dnsforge.de DNS Server hinzu: 176.9.93.198, 176.9.1.117
  7. Drücken Save
  8. Im Menü gehen wir nun auf Wireguard Server

  9. Damit die VPN Clients auch ins Internet können, tragen wir bei Post Up Script diese Zeile ein (anstelle eth0 trage dein öffentliches Interface vom Server ein):
    iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  10. Bei Post Down Script (anstelle eth0 trage dein öffentliches Interface vom Server ein):
    iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
  11. Save anklicken
  12. Im Menü auf Wireguard Clients gehen
  13. Oben rechts auf New Client klicken
  14. Einen Namen eingeben
  15. Email kann auch leer bleiben
  16. IP Allocation ist die IP, die der Client erhält (WireGuard UI zählt die IP automatisch hoch für jeden neuen Client)
  17. Allowed IPs ist das Netzwerk, welches der Client über den VPN Tunnel erreichen darf. Dort tragt ihr zusätzlich 10.252.1.0/24 ein. Default ist das komplette Internet 0.0.0.0/0 und somit auch das Routing des gesamten Traffics durch den Tunnel hinterlegt. Ihr könnt dort auch nur eurer VPN Netzwerk eintragen und der normale Internet Traffic geht dann nicht mehr durch den Tunnel.
  18. Mit Use server DNS werden die WireGuard Nameserver im Client verwendet
  19. Auf Submit drücken
  20. Um alles zu aktivieren drücken wir oben rechts auf Apply Config dann auf Apply

Der WireGuard Server ist fertig konfiguriert und eine erste Client-Konfiguration wurde erstellt.

Punkt 9: Android App installieren und einrichten

  1. Wir installieren uns aus dem F-Droid oder Google Play Store die WireGuard App (gibt es auch für iOS):
    https://f-droid.org/en/packages/com.wireguard.android
    https://play.google.com/store/apps/details?id=com.wireguard.android
  2. Öffnen die App und klicken unten rechts auf das Plus Zeichen
  3. Nun drücken wir auf VON QR_CODE SCANNEN und lesen den QR Code des erstellten Clients ein
  4. Der Tunnel erhält nun einen Namen
  5. Wir klicken auf den Tunnel und aktivieren diesen am Schalter
  6. Der Tunnel ist erfolgreich aufgebaut wenn ihr unter Transfer ein paar gesendete Daten seht
  7. Im Webinterface unter dem Menüpunkt Status seht ihr die aktive Verbindung

Punkt 10: Windows Client einrichten

Der Windows Client lässt sich hier herunterladen: https://www.wireguard.com/install/ (auch für andere Betriebssysteme werdet ihr dort fündig).

  1. Im WireGuard Webinterface auf Download klicken
  2. Startet WireGuard
  3. Klickt auf Tunnel hinzufügen und wählt eure test.conf Datei aus
  4. Nun klicken wir auf Aktivieren
  5. Der Tunnel ist nun Aktiv und es werden Daten übermittelt
  6. Automatisch verbinden bei Windows Start erreichen wir mit diesem Befehl – Eingabeaufforderung als Administrator öffnen (einmalig ausführen reicht!):
    wireguard.exe /installtunnelservice "C:\Program Files\WireGuard\Data\Configurations\test.conf.dpapi"

Punkt 11: Absichern

Auf dem Server bearbeiten wir nun unser Startscript und setzen folgende bind-address.

/etc/wireguard/start-wgui.sh

1

2

3

4

#!/bin/bash

cd /etc/wireguard

./wireguard-ui -bind-address 10.252.1.0:5000

Das default Passwort admin ändern wir in dieser Datei ab.

/etc/wireguard/db/server/users.json

1

2

3

4

{

"username": "admin",

"password": "<neues passwort>"

}

Nun starten wir den WireGuard UI Dienst neu.

1

systemctl restart wgui-web.service

Ab sofort ist euer Webinterface unter http://10.252.1.0:5000 mit eurem neuen Passwort erreichbar.

Euer adminForge Team

Das Betreiben der Dienste, Webseite und Server machen wir gerne, kostet aber leider auch Geld.
Unterstütze unsere Arbeit mit einer Spende.

10

WireGuard VPN Server mit Web Interface einrichten - adminForge (2024)

FAQs

Does WireGuard have a web interface? ›

Now you have a functioning WireGuard with a graphical user interface accessible through your browser! You can connect via IP:PORT. In this case IP:55444 The password to the panel we have set in the environment block. WireGuard GUI in a Docker environment provides a simple and effective solution for managing your VPN.

How do I connect to WireGuard VPN server? ›

Open up your web browser and paste in your server's IP address and port and hit 'Enter'. This will now take you to the login page. Simply input your username and password into the corresponding fields and click on the 'Sign In' button.

What is the password for WireGuard UI? ›

Run WireGuard-UI

⚠️ The default username and password are admin .

How to setup WireGuard VPN server on Android? ›

Install the WireGuard app for Android. Sign in to your account on our website and go to Settings -> WireGuard Configs. Select the VPN server you want to connect to. In the field below, you will get the Wireguard configuration and the QR code for the selected server.

How do I connect to a Web interface? ›

You can open your web interface by using the same IP address as your access server and pointing your web browser to this address.

Which interface does WireGuard use? ›

Simple Network Interface. WireGuard works by adding a network interface (or multiple), like eth0 or wlan0 , called wg0 (or wg1 , wg2 , wg3 , etc).

How do I use WireGuard on my computer? ›

Connect to the VPN
  1. In the WireGuard application, click on Import tunnel(s) from file.
  2. Now select the Surfshark configuration file you downloaded earlier, and hit Open.
  3. You can rename this uploaded connection to your liking. ...
  4. Lastly, to connect to the VPN, click Activate, and to disconnect from the VPN, click Deactivate.
Feb 27, 2024

Is WireGuard VPN free? ›

WireGuard is originally open source and can be used for free, absolutely.

How do I know if WireGuard server is working? ›

To check if WireGuard Server is working properly

The simpliest way is to use a cell phone with WireGuard official client app installed, turn off its Wi-Fi connection, and only connect to Internet via 3G/4G/5G.

How do I connect my phone to WireGuard server? ›

Download WireGuard® and connect to the VPN
  1. Open up the Google Play Store and search for WireGuard®. Proceed to download and install the application.
  2. Once the app is installed, open it and press + at the bottom right. ...
  3. Select the configuration file you downloaded earlier. ...
  4. Toggle the switch to activate the connection.
Jan 26, 2024

How do I find my WireGuard public key? ›

You have 2 way to do this:
  1. If connected, run sudo wg show and it will show you the public key.
  2. If not connected, run sudo awk -F' = ' '/PrivateKey/{print $2}' [path to wireguard conf] | wg pubkey.
Jun 14, 2023

Where is WireGuard public key? ›

The “WireGuard Key” is public key. It is not stored in the router. But you can use the private key in the configuration file to generate the public key to find the corresponding “WireGuard Key”.

What is the WireGuard Protocol for Android? ›

WireGuard® is a fast, lightweight, and secure VPN protocol used by default in our official Android app. We strongly recommend using our official app on your Android device. It provides the easiest way to connect to our servers and allows you to benefit from many of Proton VPN's advanced features.

How to use VPN server on Android? ›

  1. Open your device's Settings app.
  2. Tap Network & internet. VPN. If you can't find it, search for "VPN." If you still can't find it, get help from your device manufacturer.
  3. Tap the VPN you want.
  4. Enter your username and password.
  5. Tap Connect. If you use a VPN app, the app opens.

Is there a 100% free VPN Proton VPN? ›

We believe privacy should be accessible to all, which is why we have a 100% free VPN with no catches.

Does OpenVPN have a web interface? ›

Once you've completed the installation of OpenVPN Access Server you can now connect to the Access Server Admin Web UI. The following information shows you how to access the Admin Web UI and add new users and admins.

Is WireGuard or OpenVPN better? ›

SUMMARY: OpenVPN offers greater freedom when it comes to encryption and security, but WireGuard is easier to audit and has a smaller attack surface. Both protocols are very secure, but less tech-savvy users may prefer to trust the experts at WireGuard, rather than take matters into their own hands.

What is the difference between WireGuard and Tailscale? ›

Tailscale and WireGuard offer identical point-to-point traffic encryption. Using Tailscale introduces a dependency on Tailscale's security. Using WireGuard directly does not. It is important to note that a device's private key never leaves the device and thus Tailscale cannot decrypt network traffic.

How do I check WireGuard connectivity? ›

To check if WireGuard Server is working properly

The simpliest way is to use a cell phone with WireGuard official client app installed, turn off its Wi-Fi connection, and only connect to Internet via 3G/4G/5G.

Top Articles
Latest Posts
Article information

Author: Aron Pacocha

Last Updated:

Views: 5921

Rating: 4.8 / 5 (68 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Aron Pacocha

Birthday: 1999-08-12

Address: 3808 Moen Corner, Gorczanyport, FL 67364-2074

Phone: +393457723392

Job: Retail Consultant

Hobby: Jewelry making, Cooking, Gaming, Reading, Juggling, Cabaret, Origami

Introduction: My name is Aron Pacocha, I am a happy, tasty, innocent, proud, talented, courageous, magnificent person who loves writing and wants to share my knowledge and understanding with you.