Adguard Home + Wireguard (WG Easy) #1240
Replies: 1 comment 4 replies
-
|
For wg-easy version 15 (released just now): First, export your existing config, then replace your compose yaml with: services:
adguardhome:
image: adguard/adguardhome
restart: unless-stopped
ports:
# NOTE: it's not strictly necessary to map these
# ports to the host machine.
- 53:53/tcp
- 53:53/udp
- 784:784/udp
- 853:853/tcp
- 20080:80/tcp
# Only needed for the initial setup. Disable after.
- 20300:3000
volumes:
# NOTE: you can use named volumes if you don't need
# access to these files on the host machine.
- /opt/adguardhome/work:/opt/adguardhome/work
- /opt/adguardhome/conf:/opt/adguardhome/conf
cap_add:
- NET_ADMIN
networks:
private_network:
# Make sure to set this as the DNS ip in wg-easy
ipv4_address: 10.2.0.100
wg-easy:
image: ghcr.io/wg-easy/wg-easy:15
restart: unless-stopped
environment:
- HOST=0.0.0.0
- PORT=51821
- INIT_ENABLED=true
- INIT_DNS=10.2.0.100
# Set to false to disallow login from http
# (i.e. requires domain + HTTPS)
- INSECURE=true
volumes:
# NOTE: you can use named volumes for /opt/wgeasy
- /opt/wg_easy/etc/wireguard:/etc/wireguard
- /lib/modules:/lib/modules:ro
ports:
- 51820:51820/udp
- 51821:51821/tcp
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1
- net.ipv6.conf.all.disable_ipv6=0
- net.ipv6.conf.all.forwarding=1
- net.ipv6.conf.default.forwarding=1
cap_add:
- NET_ADMIN
- SYS_MODULE
networks:
private_network:
ipv4_address: 10.2.0.3
healthcheck:
test: ["CMD", "/usr/bin/timeout", "5s", "/bin/sh", "-c", "/usr/bin/wg show | /bin/grep -q interface || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 5s
start_interval: 3s
networks:
private_network:
ipam:
driver: default
config:
- subnet: 10.2.0.0/24and finally, import your config back. NOTE: if the client has no internet despite connecting, try running the following command inside your wg-easy docker container: ip route get 8.8.8.8 | awk '{print $5}'If it's not Only for my OCI VPS, I had to run a hacky script (from the host machine) to keep restarting until eth0 is the default + add routing between 10.8.0.0/24 (client subnet) and 10.2.0.0/24 (adguard home dns): click to view#!/bin/sh
WG_EASY_ID=$(docker ps --format="{{.ID}} {{.Names}}" | grep wg-easy | awk '{print $1}')
while true; do
IFACE=$(docker exec $WG_EASY_ID sh -c "ip route get 8.8.8.8 | awk '{print \$5}'")
echo "IFACE: $IFACE"
if [ "$IFACE" != "eth0" ]; then
echo "$(date): wg-easy container default route is via $IFACE, restarting..."
docker restart $WG_EASY_ID
else
docker exec "$WG_EASY_ID" sh -c "
iptables -t nat -C POSTROUTING -s 10.8.0.0/24 -d 10.2.0.0/24 -j MASQUERADE 2>/dev/null || \
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -d 10.2.0.0/24 -j MASQUERADE;
echo 'Current POSTROUTING rules for 10.8.0.0/24 → 10.2.0.0/24:';
iptables -t nat -L POSTROUTING -n -v | grep '10.8.0.0/24.*10.2.0.0/24'
"
break
fi
sleep 5
doneFor Android client on cellular (mobile data), you may also want to check if setting the MTU on the client to 1376 (instead of the default 1420) fixes it. For more details, see here: |
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
UPDATE 2025
For wireguard v15+, see my comment further below.
Original (Old Answer)
click to view (wireguard 14)
Here's a working template for adguard home + wireguard (using wg-easy image):
Please look up the respective guides on how to set this up. You will need to open port 51820 for UDP on your router ("port forwarding" section in settings).
This was updated from @walmer26's answer in March 21, 2022.
If you run into issues with port 53 being taken (most likely from systemd-resolved), see here:
Beta Was this translation helpful? Give feedback.
All reactions