Wireguard Unable to Complete Handshake on Android only 4G network
Solution 1:
MASQUERADE
/POSTROUTING
rules do not change where certain traffics go. Routes do. The problem is that you have a default route (or what's equivalent) that leads traffics into the pia
tunnel.
You will need to make use of policy routing for the replying traffics from the wireguard server:
# ip r add 192.168.1.1 dev eth0 table 123
# ip r add default via 192.168.1.1 table 123
# ip rule add iif lo ipproto udp sport 51820 lookup 123
The first command could be optional. Make sure you replace 192.168.1.1
and eth0
with the LAN IP of your router and the interface name of your Ethernet NIC correspondingly. (You can copy them from the output of ip r
, i.e. routes in the main table.) The number 123
is arbitrary. iif lo
limits the rule to UDP traffics with source port of 51820
from the host itself (but not such traffics from another host).