---
title: '🔒 Virtual Private Networking'
url: 'https://www.handtrixxx.com/en/wiki/free-open-source-software/virtual-private-networking'
markdown: 'https://www.handtrixxx.com/en/wiki/free-open-source-software/virtual-private-networking.md'
lang: en
date: '2026-03-14'
description: '🔒 Virtual Private Networking The VPN is not to be confused with a DMZ: resources that we want to provide publicly on the internet belong in this DMZ, which is provided in combination of the Traefik reverse proxy and a further Docker network. Here we build the following: A Wireguard network for th…'
---

#  Virtual Private Networking 

The VPN is not to be confused with a DMZ: resources that we want to provide publicly on the internet belong in this DMZ, which is provided in combination of the Traefik reverse proxy and a further Docker network.

Here we build the following:

- A Wireguard network for the encrypted communication of our own resources – VPS, home server, and further clients.
- A Wireguard network for the encrypted communication between our VPS and the internet.

Both networks run virtualized, independently, and separately from each other.

![](https://www.handtrixxx.com/user/pages/wiki/free-open-source-software/virtual-private-networking/diagram.svg)

## Server setup

On our VPS we create an own internal VPN network with Wireguard, in which the VPS is treated as server and the home server as well as other devices as clients.

Additionally we build another VPN via a different way, in which it is about that the VPS optionally itself can build up an as anonymous as possible connection to further resources from the internet.

### Internal network

To provide a Wireguard VPN we use "[wg-easy](https://wg-easy.github.io/wg-easy/latest/)", a tool that, operated as a Docker container, delivers not only a Wireguard server as such, but also a web UI for it and simplifies the configuration.

The `compose.yml` for that can e.g. look like this:

```yaml
services:
    wg-easy:
        image: ghcr.io/wg-easy/wg-easy:15
        container_name: wg-easy
        environment:
            - WG_HOST=PUBLIC-IPv4-ADDRESS-OF-THE-SERVER
            - WG_PORT=51820
            - WG_DEFAULT_ADDRESS=10.8.0.x # or another address range
            - WG_DEFAULT_DNS= # yes, deliberately empty, so that the DNS config of the clients is not overwritten
            - WG_ALLOWED_IPS=10.42.42.0/24,fdcc:ad94:bacf:61a3::/64 # additional security factor
            - INSECURE=false
        networks:
            wg:
                ipv4_address: 10.42.42.42
                ipv6_address: fdcc:ad94:bacf:61a3::2a
        volumes:
            - ./config:/etc/wireguard # for the config
            - /lib/modules:/lib/modules:ro # for hardware-accelerated Wireguard encryption
        ports:
            - "51820:51820/udp"  # Do not forget the release in the firewall!
            - "51821:51821/tcp"  # Do not forget the release in the firewall!
        restart: unless-stopped
        cap_add:
            - NET_ADMIN
            - SYS_MODULE
        sysctls:
            - net.ipv4.ip_forward=1
            - net.ipv4.conf.all.src_valid_mark=1
            - net.ipv6.conf.all.disable_ipv6=0
            - net.ipv6.conf.all.forwarding=1
            - net.ipv6.conf.default.forwarding=1
networks:
    wg:
        driver: bridge
        enable_ipv6: true
        ipam:
            driver: default
            config:
                - subnet: 10.42.42.0/24
                - subnet: fdcc:ad94:bacf:61a3::/64
```

So that the clients can later connect too, we release the Wireguard port `51820` for UDP and the port `51821` for TCP in the firewall of our VPS.

## Home server setup

On the home server we set up the Wireguard client in the form of a Docker container.

`compose.yml`:

```yaml
services:
    wireguard:
        image: lscr.io/linuxserver/wireguard:latest
        container_name: wireguard
        cap_add:
            - NET_ADMIN
            - SYS_MODULE
        environment:
            - PUID=1000
            - PGID=1000
            - TZ=Europe/Berlin
        volumes:
            - ./config:/config
            - /lib/modules:/lib/modules:ro
        network_mode: host
        restart: unless-stopped
```

## Further clients

### Linux

For Debian-based distributions:

`client.conf`:

```ini
[Interface]
PrivateKey = PRIVATE_KEY
Address = 10.8.0.X/24
MTU = 1420
DNS =

[Peer]
PublicKey = PUBLIC_KEY
PresharedKey = PRESHARED_KEY
AllowedIPs = 10.42.42.0/24,10.8.0.0/24,fdcc:ad94:bacf:61a3::/64
PersistentKeepalive = 30
Endpoint = VPS_PUBLIC_IPv4:51820
```

## Sources and links

- Wireguard server "wg-easy"
- Wireguard Docker client from linuxserver.io

---

## Navigation

- Parent: [Free Open-Source Software](https://www.handtrixxx.com/en/wiki/free-open-source-software.md)
- Previous: [🔍 SearxNG](https://www.handtrixxx.com/en/wiki/free-open-source-software/searxng.md)
- Next: [🖥️ Webtop](https://www.handtrixxx.com/en/wiki/free-open-source-software/webtop.md)
