I have a paid external vpn(Nordvpn using gluetun) and am currently hosting my own wireguard vpn on my server through docker. is there a way to get the traffic from my selfhosted vpn to tunnel through my paid vpn? This is my docker-compose file atm.
services:
gluetun_test:
image: qmcgaw/gluetun
container_name: gluetun_test
cap_add:
- NET_ADMIN
ports:
- "5010:5000"
# Port of the WireGuard VPN server
- "36843:36843/udp"
environment:
- VPN_SERVICE_PROVIDER=nordvpn
- VPN_TYPE=wireguard
- WIREGUARD_PRIVATE_KEY=redacted
- SERVER_COUNTRIES=United Kingdom
wireguard:
image: linuxserver/wireguard:latest
container_name: wireguard
cap_add:
- NET_ADMIN
environment:
- PUID=1000
- PGID=1000
volumes:
- ./wireguard/config:/config
# ports:
# Port for WireGuard-UI
# - "5010:5000"
# Port of the WireGuard VPN server
# - "36843:36843/udp"
network_mode: service:gluetun_test
wg0.conf
[Interface]
Address = 10.252.1.0/24
ListenPort = 36843
PrivateKey = redacted
MTU = 1450
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
Table =
Any help would be great! Thanks!
Sorry, I am not super clear of what you are asking.
You do have
gluetun
which is used to connect to NordVPN. Then you havewireguard
, to which you connect from somewhere, and you want essentially:client -> wireguard -> wireguard container -> gluetun container -> internet?
Yeah, this is correct. I have a self-hosted Wireguard VPN which i connect to and i want my internet traffic to go through the gluetun docker through nordvpn. client -> wireguard container -> gluetun container -> internet
https://www.youtube.com/watch?v=xbSfaKwyfXE
This should help
This didnt seem to help much. My problem is that when i tell the wireguard server to use gluetun as its network mode, i can not get any traffic to go from the client -> wireguard(my own server) -> gluetun(connected to nordvpn) -> internet as i want.
ip rule add from WG-NET table TABLE ip route add default via GLUETUN-GW dev GLUETUN-DEV src GLUETUN-IP table TABLE ip route add WG-NET dev WG-DEV src WG-IP
First one causes all packets coming from wireguard network to use the routing table TABLE, second one sets the default gateway in that table to gluetun, third one sets up routing back to the wireguard network (this one probably already exists)
Where
- TABLE: A routing table name, mapped in /etc/iproute2/rt_tables
- GLUETUN-GW: The gateway IP of the gluetun tunnel, e.g. 10.128.1.1
- GLUETUN-DEV: The gluetun tunnel netdev, e.g. tap0
- GLUETUN-IP: The gluetun tunnel device’s IP (your machine), e.g. 10.128.1.2
- WG-NET: your wireguard network, e.g. 10.100.0.0/24
- WG-DEV: The wireguard network device, e.g. wg0
- WG-IP: The wireguard network device’s IP (your machine), e.g. 10.100.0.1
Untested, so not sure if it works.
Would this be put in the post up part of wg0?
having the very same idea and issue u described, any idea on how to solv it? my post here https://www.reddit.com/r/WireGuard/comments/1abnvyj/need_help_with_idea_wireguard_and_gluetun/