I've read countless forum posts and documentation and I am now really confused after having spent many hours with this problem.
I have set up Wireguard on my router using the script I found in the documentation. I would like to connect to Wireguard from my Android phone vie LTE and remotely access my Raspberry Pi connected to the router. The issue is that I can SSH into the router, but I cannot access the Raspberry Pi. The SSH request just keeps hanging.
What has worked, however, is enabling masquerading on the LAN zone. That works wonderfully and I can connect to the Raspberry Pi without an issue. However, I have read many times that enabling masquerading in the LAN zone isn't needed (as opposed to the WAN zone where it's enabled) and I wondered if there is another option available? I wouldn't want problems to unexpectedly start appearing elsewhere because of masquerading being switched on in the LAN zone.
Maybe you can put wireguard interface into a new firewall zone like "vpn" which allow input,output,redirect data,and allow data redirect from and to zone "lan"。then you can enable masquerading in zone "vpn" only.
Is the router running OpenWrt and Wireguard server also the main router in the home network?
If it is not, there will be a problem routing back to the 10.0.5.0 tunnel, unless the tunnel is masqueraded into the LAN. That causes packets from the phone to be modified to appear to have come from the wireguard server's LAN address instead of a 10.0.5 IP which the LAN is not aware of.
This is wrong. For an option like network that can be set more than once, use list instead of option.
list network 'lan'
list network 'wg_lan'
Below is the deprecated old syntax which may or may not still work:
option network 'lan wg_lan'
Replace this with list network on two lines.
Masquerading requires the traffic to be between two different zones (having both in the lan zone as above will not work) and the option masq is set on the destination zone.
Log into the Pi from the LAN, and with the phone connected to the VPN via LTE, see if you can ping the phone's tunnel IP.
Are you testing from a remote network (i.e. cellular or a different wifi network)? If so, what is the result of these ping tests (from your mobile phone):
Do you have other devices on your network that you can try to connect to? Ideally not windows based machines... a mac or linux system should be the best.
I suspect that there is something on your RPi that is blocking the inbound ssh from a different subnet. You actually shouldn't need the explicit ufw rules on your pi.... normally these things work without any additional rules.
Oh no, I've tried to SSH into a different Linux machine and it worked fine from my phone over LTE! So something must be messed up with the RPi. I wouldn't have suspected that! Thank you so much for your patience, now I'll go and try to debug the RPi...