Hi I am struggling setting up my network. I habe a VPS on the internet and a home network which I want to connect via docker wireguard. On the VPS will be a wireguard container as server and a SWAG container
docker-yaml:
version: "3"
services:
swag:
image: lscr.io/linuxserver/swag:latest
container_name: reverse_proxy
hostname: "swag"
networks:
proxy:
ipv4_address: 10.2.0.10
cap_add:
- NET_ADMIN
environment:
- PUID=1001
- PGID=1001
- TZ=Europe/London
- URL=my.domain.de
- VALIDATION=dns
- SUBDOMAINS=wildcard
- DNSPLUGIN=my.plugin
- EMAIL=my.email@provider.com
volumes:
- ./swag:/config
ports:
- 443:443
- 80:80 #optional
restart: unless-stopped
wireguard:
depends_on: [unbound, pihole]
image: linuxserver/wireguard
container_name: wireguard
cap_add:
- NET_ADMIN
- SYS_MODULE
environment:
- PUID=1001
- PGID=1001
- TZ=Europe/London # Change to your timezone
- SERVERPORT=51820
- SERVERURL=1.2.3.4
- PEERS=3
- INTERNAL_SUBNET=10.2.2.0
volumes:
- ./wireguard:/config
- /lib/modules:/lib/modules
ports:
- 51820:51820/udp
- 25565:25565 # Port I want to forward
- 32400:32400 # Port I want to forward
sysctls:
- net.ipv4.conf.all.src_valid_mark=1
restart: unless-stopped
networks:
proxy:
ipv4_address: 10.2.0.40
networks:
proxy:
name: proxy
driver: bridge
ipam:
config:
- subnet: 10.2.0.0/24
gateway: 10.2.0.1
my wg0.conf at server site looks like:
[Interface]
Address = 10.2.2.1
ListenPort = 51820
PrivateKey = xxxxxxxxxxxxxxxxx
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth+ -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth+ -j MASQUERADE
[Peer]
# peer_plex
PublicKey = xxxxxxxxxxxxxxx
PresharedKey = xxxxxxxxxxxxxxxx
AllowedIPs = 10.2.2.2/32
[Peer]
# peer_minecraft
PublicKey = xxxxxxxxxxxxx
PresharedKey =xxxxxxxxxxxxxxxxxxxxx
AllowedIPs = 10.2.2.3/32
and on the client site I have a gluetun container and some other container (minecraft server with network: service:gluetun). The Firewall option in gluetun is disabled.
My Problem is, I want to set the reverse proxy to my one client with my Plex server at 10.2.2.2:32400 but my reverse_proxy container has no connection to this client.
And I want to Port forward a VPS port (via port mapping) to my minecraft client.
I can without a problem ping from 10.2.2.2 to 10.2.0.1 or 10.2.2.1 but only my wireguard server at 10.2.2.1 can ping 10.2.2.2. The reverse_proxy at 10.2.0.10 cannot ping 10.2.2.2. And the same with the minecraft-client at 10.2.2.3.
I tried editing the wg0.conf server site with PostUp and PostDown
PostUp=...
PostUp=iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 25565 -j DNAT --to 10.2.2.3:25565
and the same for PostDown but this only resolted in seeing the ping and the online status of the minecraft server but i could not log in. tcpdump showed me that no packages where going out (length=0) only coming in.
13:37:51.950636 IP home.ip.2784 > server.ip.25565: Flags [.], ack 1079, win 1020, options [nop,nop,sack 1 {3839:4005}], length 0
And for the Plex Server
PostUp=...
PostUp=iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 32400 -j DNAT --to 10.2.2.2:32400
I am not quite sure what to do. I also tried using the linuxserver/wireguard container as client but then even pinging from the server didn’t work. I am rather new to the whole vpn stuff and routing via ip route or iptables is not at all my area. Can someone help me or is it even possible right now?