cd /home/myusername/docker
mkdir wireguard && cd "$_"
services:
wireguard:
image: linuxserver/wireguard
container_name: wireguard
restart: unless-stopped
cap_add:
- NET_ADMIN
- SYS_MODULE
environment:
PUID: 1000
PGID: 1000
TZ: Etc/UTC
SERVERURL: auto # (wireguard.DOMAIN.COM)(192.168.1.100)
SERVERPORT: 51820 #optional
PEERS: 1 #optional
PEERDNS: auto #optional
INTERNAL_SUBNET: 10.13.13.0 #optional
sysctls:
- net.ipv4.conf.all.src_valid_mark=1
volumes:
- ./config:/config
- /lib/modules:/lib/modules
ports:
- 51820:51820/udp
docker compose up -d
WireGuard client Windows: https://www.wireguard.com/install/
WireGuard client Linux: https://github.com/UnnoTed/wireguird
cd /home/myusername/docker/wireguard-server/config/peer1
docker exec -it wireguard /app/show-peer 1
services:
wg-easy:
image: ghcr.io/wg-easy/wg-easy:latest
container_name: wireguard-webui
restart: unless-stopped
environment:
WG_HOST: vpn.DOMAIN.COM # (vpn.DOMAIN.COM) or local server ip (192.168.1.100)
PASSWORD: wireguard # When set, requires a password when logging in to the Web UI.
#WG_PORT: 51820 # The public UDP port of your VPN server. (if disabled default is: 51820)
WG_DEFAULT_ADDRESS: 10.13.13.x # Clients IP address range.
#WG_DEFAULT_DNS: 1.1.1.1 # DNS server clients will use. If set to blank value, clients will not use any DNS. (if disabled default is: 1.1.1.1)
#WG_DEVICE: eth0 # Ethernet device the wireguard traffic should be forwarded through. (if disabled default is: eth0)
#LANG: en # Web UI language (Supports: en, ru, tr, no, pl, fr, de, ca, es) (if disabled default is: en)
#WG_MTU: 1420 # The MTU the clients will use. (if disabled default is: null)
#WG_ALLOWED_IPS: 192.168.15.0/24, 10.0.1.0/24 # Allowed IPs clients will use.
#WG_PRE_UP: echo "Pre Up" > /etc/wireguard/pre-up.txt
#WG_POST_UP: echo "Post Up" > /etc/wireguard/post-up.txt
#WG_PRE_DOWN: echo "Pre Down" > /etc/wireguard/pre-down.txt
#WG_POST_DOWN: echo "Post Down" > /etc/wireguard/post-down.txt
volumes:
- ./data:/etc/wireguard
ports:
- "51820:51820/udp"
- "51821:51821/tcp"
cap_add:
- NET_ADMIN
- SYS_MODULE
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1
docker compose up -d