---
title: 'Virtual Private Networking'
url: 'https://www.handtrixxx.com/de/wiki/self-hosted/virtual-private-networking'
markdown: 'https://www.handtrixxx.com/de/wiki/self-hosted/virtual-private-networking.md'
lang: de
date: '2026-03-14'
description: 'Virtual Private Networking Das VPN ist nicht mit einer DMZ zu verwechseln: Ressourcen, die wir öffentlich im Internet bereitstellen wollen, gehören in diese DMZ, welche in Kombination aus Traefik-Reverse-Proxy und einem weiteren Docker-Netzwerk bereitgestellt wird. Hier bauen wir folgendes auf: Ei…'
---

#  Virtual Private Networking 

Das VPN ist nicht mit einer DMZ zu verwechseln: Ressourcen, die wir öffentlich im Internet bereitstellen wollen, gehören in diese DMZ, welche in Kombination aus Traefik-Reverse-Proxy und einem weiteren Docker-Netzwerk bereitgestellt wird.

Hier bauen wir folgendes auf:

- Ein Wireguard-Netzwerk für die verschlüsselte Kommunikation unserer eigenen Ressourcen – VPS, Homeserver und weitere Clients.
- Ein Wireguard-Netzwerk für die verschlüsselte Kommunikation zwischen unserer VPS und dem Internet.

Beide Netze laufen virtualisiert, unabhängig und getrennt voneinander.

![](https://www.handtrixxx.com/user/pages/wiki/02.self-hosted/virtual-private-networking/diagram.svg)

## Server-Setup

Auf unserer VPS erstellen wir ein eigenes internes VPN-Netzwerk mit Wireguard, bei dem die VPS als Server und der Homeserver sowie andere Geräte als Clients behandelt werden.

Außerdem bauen wir auf einem anderen Weg ein weiteres VPN auf, bei dem es darum geht, dass der VPS optional selbst eine möglichst anonyme Verbindung zu weiteren Ressourcen aus dem Internet aufbauen kann.

### Internes Netzwerk

Um ein Wireguard-VPN bereitzustellen, nutzen wir „[wg-easy](https://wg-easy.github.io/wg-easy/latest/)“, ein Tool, das als Docker-Container betrieben nicht nur einen Wireguard-Server an sich liefert, sondern auch eine Web-UI dafür und die Konfiguration vereinfacht.

Die `compose.yml` dafür sieht z. B. so aus:

```yaml
<span class="hljs-attr">services:</span>
    <span class="hljs-attr">wg-easy:</span>
        <span class="hljs-attr">image:</span> <span class="hljs-string">ghcr.io/wg-easy/wg-easy:15</span>
        <span class="hljs-attr">container_name:</span> <span class="hljs-string">wg-easy</span>
        <span class="hljs-attr">environment:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">WG_HOST=ÖFFENTLICHE-IPv4-ADRESSE-DES-SERVERS</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">WG_PORT=51820</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">WG_DEFAULT_ADDRESS=10.8.0.x</span> <span class="hljs-comment"># oder ein anderer Adressbereich</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">WG_DEFAULT_DNS=</span> <span class="hljs-comment"># ja, mit Absicht leer, damit die DNS-Config der Clients nicht überschrieben wird</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">WG_ALLOWED_IPS=10.42.42.0/24,fdcc:ad94:bacf:61a3::/64</span> <span class="hljs-comment"># zusätzlicher Sicherheitsfaktor</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">INSECURE=false</span>
        <span class="hljs-attr">networks:</span>
            <span class="hljs-attr">wg:</span>
                <span class="hljs-attr">ipv4_address:</span> <span class="hljs-number">10.42</span><span class="hljs-number">.42</span><span class="hljs-number">.42</span>
                <span class="hljs-attr">ipv6_address:</span> <span class="hljs-string">fdcc:ad94:bacf:61a3::2a</span>
        <span class="hljs-attr">volumes:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">./config:/etc/wireguard</span> <span class="hljs-comment"># für die Config</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">/lib/modules:/lib/modules:ro</span> <span class="hljs-comment"># für hardwarebeschleunigte Wireguard-Verschlüsselung</span>
        <span class="hljs-attr">ports:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">"51820:51820/udp"</span>  <span class="hljs-comment"># Freigabe in der Firewall nicht vergessen!</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">"51821:51821/tcp"</span>  <span class="hljs-comment"># Freigabe in der Firewall nicht vergessen!</span>
        <span class="hljs-attr">restart:</span> <span class="hljs-string">unless-stopped</span>
        <span class="hljs-attr">cap_add:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">NET_ADMIN</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">SYS_MODULE</span>
        <span class="hljs-attr">sysctls:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">net.ipv4.ip_forward=1</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">net.ipv4.conf.all.src_valid_mark=1</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">net.ipv6.conf.all.disable_ipv6=0</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">net.ipv6.conf.all.forwarding=1</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">net.ipv6.conf.default.forwarding=1</span>
<span class="hljs-attr">networks:</span>
    <span class="hljs-attr">wg:</span>
        <span class="hljs-attr">driver:</span> <span class="hljs-string">bridge</span>
        <span class="hljs-attr">enable_ipv6:</span> <span class="hljs-literal">true</span>
        <span class="hljs-attr">ipam:</span>
            <span class="hljs-attr">driver:</span> <span class="hljs-string">default</span>
            <span class="hljs-attr">config:</span>
                <span class="hljs-bullet">-</span> <span class="hljs-attr">subnet:</span> <span class="hljs-number">10.42</span><span class="hljs-number">.42</span><span class="hljs-number">.0</span><span class="hljs-string">/24</span>
                <span class="hljs-bullet">-</span> <span class="hljs-attr">subnet:</span> <span class="hljs-string">fdcc:ad94:bacf:61a3::/64</span>
```

Damit sich die Clients später auch verbinden können, geben wir in der Firewall unserer VPS den Wireguard-Port `51820` für UDP und den Port `51821` für TCP frei.

## Homeserver-Setup

Auf dem Homeserver setzen wir den Wireguard-Client in Form eines Docker-Containers auf.

`compose.yml`:

```yaml
<span class="hljs-attr">services:</span>
    <span class="hljs-attr">wireguard:</span>
        <span class="hljs-attr">image:</span> <span class="hljs-string">lscr.io/linuxserver/wireguard:latest</span>
        <span class="hljs-attr">container_name:</span> <span class="hljs-string">wireguard</span>
        <span class="hljs-attr">cap_add:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">NET_ADMIN</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">SYS_MODULE</span>
        <span class="hljs-attr">environment:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">PUID=1000</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">PGID=1000</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">TZ=Europe/Berlin</span>
        <span class="hljs-attr">volumes:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">./config:/config</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">/lib/modules:/lib/modules:ro</span>
        <span class="hljs-attr">network_mode:</span> <span class="hljs-string">host</span>
        <span class="hljs-attr">restart:</span> <span class="hljs-string">unless-stopped</span>
```

## Weitere Clients

### Linux

Für Debian-basierte Distributionen:

`client.conf`:

```ini
<span class="hljs-section">[Interface]</span>
<span class="hljs-attr">PrivateKey</span> = PRIVATE_KEY
<span class="hljs-attr">Address</span> = <span class="hljs-number">10.8</span>.<span class="hljs-number">0</span>.X/<span class="hljs-number">24</span>
<span class="hljs-attr">MTU</span> = <span class="hljs-number">1420</span>
<span class="hljs-attr">DNS</span> =

<span class="hljs-section">[Peer]</span>
<span class="hljs-attr">PublicKey</span> = PUBLIC_KEY
<span class="hljs-attr">PresharedKey</span> = PRESHARED_KEY
<span class="hljs-attr">AllowedIPs</span> = <span class="hljs-number">10.42</span>.<span class="hljs-number">42.0</span>/<span class="hljs-number">24</span>,<span class="hljs-number">10.8</span>.<span class="hljs-number">0.0</span>/<span class="hljs-number">24</span>,fdcc:ad94:bacf:<span class="hljs-number">61</span>a3::/<span class="hljs-number">64</span>
<span class="hljs-attr">PersistentKeepalive</span> = <span class="hljs-number">30</span>
<span class="hljs-attr">Endpoint</span> = VPS_PUBLIC_IPv4:<span class="hljs-number">51820</span>
```

## Quellen und Links

- Wireguard-Server „wg-easy“
- Wireguard-Docker-Client von linuxserver.io

 self-hostedvpnprivacynetwork

---

## Navigation

- Parent: [Selbst gehostet](https://www.handtrixxx.com/de/wiki/self-hosted.md)
- Previous: [Stalwart](https://www.handtrixxx.com/de/wiki/self-hosted/stalwart.md)
- Next: [VS Code Server](https://www.handtrixxx.com/de/wiki/self-hosted/vs-code-server.md)
