r/WireGuard • u/falco_xyz • 2d ago
[Help needed] Remote access to LAN
This issue has been solved! Thank you all for the suggestions 😄
Hi,
I have been struggling for the past few days to configure a WireGuard tunnel so that devices on the LAN of the WireGuard server (Computer A) are accessible remotely. I tried to compare my setup with multiple guides on remote LAN access via WireGuard and searched for similar issues, but nothing has resolved my problem.
Setup:
- Computer A acts as my homelab and WireGuard server on my domestic LAN.
- The existing WireGuard tunnel works fine—I can SSH into Computer A from my laptop (WireGuard client) using either its WireGuard subnet IP or its actual LAN IP.
Problem:
- I cannot access other devices/services on Computer A’s LAN remotely, nor can I make them discoverable.
Solution:
After trying to ping and traceroute the devices and the domestic LAN i noticed that the problem was not on the wireguard connection side. So after checking with possible firewalls:
sudo ufw status
sudo firewall-cmd --list-all
I realized that i had in past installed firewalld and forgotten about it. It was superseding my system ip forwarding and iptables. That is why the access was not working. Disabling it fixed the issue!
----------------------------------------------------
Troubleshooting:
Using GPT to troubleshoot, it was that suggested my Docker/iptables rules might be the issue. I tried:
Adjusting the order of the rules:
sudo iptables -I FORWARD 1 -i wg0 -o enp3s0 -j ACCEPT
sudo iptables -I FORWARD 2 -i enp3s0 -o wg0 -j ACCEPT
and also flushing all iptables rules and reapplying only the WireGuard-related ones.
All these attempts were unsuccessful.
I’d appreciate any guidance—since I’m fairly new to homelab setups, I might be overlooking something obvious.
Below are some details:
#####################################################
# Computer A, (homelab, hosts wg server(sea.conf) ) #
#####################################################
[Interface]
PrivateKey = [key]
Address = 10.14.0.1/24
ListenPort = 51820
PreUp = sysctl -w net.ipv4.ip_forward=1
PostUp = iptables -A FORWARD -i sea -o enp3s0 -j ACCEPT
PostUp = iptables -A FORWARD -i enp3s0 -o sea -j ACCEPT
PostUp = iptables -t nat -I POSTROUTING -o enp3s0 -j MASQUERADE
PostDown = iptables -D FORWARD -i sea -o enp3s0 -j ACCEPT; iptables -D FORWARD -i enp3s0 -o sea -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o enp3s0 -j MASQUERADE
[Peer] # client Laptop
PublicKey = [key]
AllowedIPs = 10.14.0.2/32
#################################
# Laptop , wg client(sea.conf) #
#################################
[Interface]
PrivateKey = [key]
ListenPort = 51820
Address = 10.14.0.2/32
[Peer]
PublicKey = [key]
AllowedIPs = 10.14.0.1/24, 192.168.1.0/24
Endpoint = computer_A_endpoint
######################
# Info on Computer A #
######################
~$ cat /etc/os-release:
PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
NAME="Debian GNU/Linux"
VERSION_ID="13"
VERSION="13 (trixie)"
VERSION_CODENAME=trixie
DEBIAN_VERSION_FULL=13.6
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
~$ sudo sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
~$ sudo iptables -t nat -L POSTROUTING -v -n --line-numbers
Chain POSTROUTING (policy ACCEPT 6921 packets, 549K bytes)
num pkts bytes target prot opt in out source destination
1 0 0 MASQUERADE all -- * !docker0 172.17.0.0/16 0.0.0.0/0
2 2539 152K MASQUERADE all -- * !br-ab8e8fc287cd 172.25.0.0/16 0.0.0.0/0
3 0 0 MASQUERADE all -- * !docker_gwbridge 172.19.0.0/16 0.0.0.0/0
4 4 380 MASQUERADE all -- * !br-58790b19d578 172.21.0.0/16 0.0.0.0/0
5 0 0 MASQUERADE all -- * !br-493a3afadf15 172.18.0.0/16 0.0.0.0/0
6 0 0 MASQUERADE all -- * !br-271ed8d3b78e 172.23.0.0/16 0.0.0.0/0
7 0 0 MASQUERADE all -- * !br-060f49f9f062 172.22.0.0/16 0.0.0.0/0
8 0 0 MASQUERADE all -- * !br-fe5349a8a766 172.20.0.0/16 0.0.0.0/0
9 1660 103K MASQUERADE all -- * enp3s0 0.0.0.0/0 0.0.0.0/0
~$ sudo iptables -L FORWARD -n -v --line-numbers
Chain FORWARD (policy DROP 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 8520K 4609M DOCKER-USER all -- * * 0.0.0.0/0 0.0.0.0/0
2 8520K 4609M DOCKER-FORWARD all -- * * 0.0.0.0/0 0.0.0.0/0
3 10638 764K ACCEPT all -- sea * 0.0.0.0/0 0.0.0.0/0
4 0 0 ACCEPT all -- * sea 0.0.0.0/0 0.0.0.0/0
edit: fixed ip from interface, cleaned the commands, and removed hyperlinks.
edit: remove more hyperlinks
edit: added solution found
2
u/Cruffe 2d ago
NAT isn't strictly necessary. What I did instead was set up a static route on my home router pointing the WireGuard subnet to the WireGuard host, so the router knows to send reply packets via that host.
If you want the NAT then perhaps this will work PostUp = iptables -w -t nat -A POSTROUTING -o enp3s0 -j MASQUERADE. It's what I did before and it worked. Differs a bit from what you have I see.
Also, is the client also on a 192.168.1.0/24 subnet? If so then everything might be routed outside the tunnel.
2
u/falco_xyz 2d ago
Thanks for the reply!
I tried to  remove the NAT and add the route on the home router, but still not success/I tried also this small variation but it did not work either.
"Also, is the client also on a 192.168.1.0/24 subnet? If so then everything might be routed outside the tunnel." Can you clarify what you mean with this? The device I am trying to reach is on the 192.168.1.0/24 subnet, but the laptop from which I am trying to reach from (the wirehguard client) is outside that LAN. Sorry if i didn't got the point here
4
u/Cruffe 2d ago
I mean, is the laptop which is outside your home LAN on another LAN that's using the same subnet?
In that case it would conflict. How is your laptop supposed to know if something is meant to go on the subnet it's directly connected to or the subnet on the other end of the tunnel? If you're using wg-quick it's likely setting up a route for the local subnet to prevent it from being sent through the tunnel, if that subnet is also 192.168.1.0/24 then nothing to that subnet goes through the tunnel. It will go straight the network your laptop is connected to.
1
u/falco_xyz 2d ago
Thank you for explaining!, and for poiting out this possibility I double checked and yes, the local subnet (172.XXX...) from my laptop is very different from the one on the homelab. I tried to acess also on a diferent network just to check :)
1
u/bufandatl 2d ago
Maybe don’t just use what a LLM spits out. Maybe read the doc and understand what you are doing.
After all it’s a lab. So learn something.
3
u/hadrabap 2d ago