almost same as this article
Wireguard use one client as gateway of another
but i have wireguard in docker so i can't understand how to solve my routing problem
peer1 --- wireguard_server(in docker) --- peer2 --- internet
peer1: 10.14.1.2
wireguard_server: 10.14.1.1
peer2: 10.14.1.3
My docker-compose.yml
---
version: "2.1"
services:
wireguard:
image: lscr.io/linuxserver/wireguard:latest
container_name: wireguard
cap_add:
- NET_ADMIN
- SYS_MODULE
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Nicosia
- SERVERURL=auto #optional
- SERVERPORT=51820 #optional
- PEERS=2 #optional
- PEERDNS=auto #optional
- INTERNAL_SUBNET=10.14.1.0 #optional
- ALLOWEDIPS=0.0.0.0/0 #optional
- PERSISTENTKEEPALIVE_PEERS=all #optional
- LOG_CONFS=true #optional
volumes:
- /root/wireguard/config:/config
- /lib/modules:/lib/modules #optional
ports:
- 51820:51820/udp
sysctls:
- net.ipv4.conf.all.src_valid_mark=1
restart: unless-stopped
My actions on wireguard_server
docker exec -it wireguard bash
ip rule add from 10.14.1.2 lookup 200
ip route add default dev wg0 table 200
sysctl -w net.ipv4.ip_forward=1 - execute on host, not in docker
After that i change wg0.conf for peer2
AllowedIPs = 0.0.0.0/5,8.0.0.0/7,10.14.1.3/32,11.0.0.0/8,12.0.0.0/6,16.0.0.0/4,32.0.0.0/3,64.0.0.0/2,128.0.0.0/1
i don't see any traffic on peer2 from peer1