0

I have vps with ubuntu onboard and installed wireguard. Also I have a home network: router + several laptops. I want connect my router to vps and have access from vps to any laptops.

I run wirequard with docker compose:

  wireguard:
    image: linuxserver/wireguard
    container_name: wireguard
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London #set correct timezone
      - SERVERPORT=51820 #optional
      - PEERS=green #optional
      - PEERDNS=auto #optional
      - ALLOWEDIPS=0.0.0.0/0 #Peer addresses allowed
      - INTERNAL_SUBNET=10.13.13.0/24 #Subnet used in VPN tunnel
      - SERVERURL=example.org #Wireguard VPN server address
    volumes:
      - ~/apps/wireguard/config:/config
      - /lib/modules:/lib/modules
    ports:
      - 51820:51820/udp

This is my wg0.conf:

[Interface]
Address = 10.13.13.1
ListenPort = 51820
PrivateKey = 
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

[Peer]
# peer_green
PublicKey = 
PresharedKey = 
AllowedIPs = 10.13.13.2/32, 192.168.1.0/24

Peer config:

[Interface]
Address = 10.13.13.2
PrivateKey = 
ListenPort = 51820
DNS = 10.13.13.1

[Peer]
PublicKey = 
PresharedKey = 
Endpoint = example.org:51820
AllowedIPs = 0.0.0.0/0

I can connect to wireguard with router, but I can't ping router or any devices from vps. Also I doesn't see any router on my ps with "ip route". How to make LAN reachable from my vps or my laptop connected to vps?

enter image description here

10
  • sounds like you need to add a route to your LAN using wg0 as its interface. Commented Sep 19, 2022 at 16:34
  • do you have any example?
    – Roman N
    Commented Sep 19, 2022 at 16:50
  • ip route add {LAN_NETWORK/MASK} via {GATEWAYIP} dev wg0 cyberciti.biz/faq/… Commented Sep 19, 2022 at 16:53
  • how to make this ip route permanent? (I use ubuntu)
    – Roman N
    Commented Sep 19, 2022 at 17:06
  • did adding the route resolve the issue? Commented Sep 19, 2022 at 19:07

1 Answer 1

1

Do not use AllowedIPs = 0.0.0.0/0 use 10.13.13.0/24 and use PersistentKeepalive = 25. If you still cannot connection over vpn, you should do masquearate docker tunnel.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Oct 17, 2022 at 13:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .