Score:1

Use wireguard client as default gateway of another (server in docker)

ru flag

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

Paul Perrick avatar
iq flag
Working on something similar, but maybe in an lxc or even a vm. I hope someone helps out. My knowledge of routing tables, especially inside a docker container, is dreadfully incomplete.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.