I'm trying to set up a VPN gateway (using LXD containers). I'm using ufw for killswitch service. Almost all is working except port forwarding.
┌─────────────────────────┐ ┌──────────────────────────┐
│ SECOND CONTAINER │ │ OVPN CLIENT CONTAINER │
│ │ │ │ ┌─────────────┐
│ 192.168.1.3 │ LAN │ 192.168.1.2 │ VPN TUNNEL │ │
│ gw:192.168.1.2 eth0├──────────────────┤eth0 tun0 ├────────────────┤ VPN NODE │
│ │ │ │ │ │
│ HTTP test server in │ │ │ └──┬──────────┘
│ 8107 port │ │ │ │
└─────────────────────────┘ └──────────────────────────┘ │
xxxxxxxxxxxx
xxxx xxx
xxx x
xx INTERNET x
xxx xxx
xxxx xxxx
xxxxx
In my VPN gateway I have:
ufw status
192.168.1.0/24 ALLOW Anywhere
192.168.1.0/24 ALLOW OUT Anywhere
Anywhere ALLOW OUT Anywhere on tun0
<myvpnremoteip> 1194/tcp ALLOW OUT Anywhere #vpn remote address
before.rules extract:
*nat
:POSTROUTING ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]
-A PREROUTING -i eth0 -p tcp --dport 8701 -j DNAT --to-destination 192.168.1.3
-A POSTROUTING -s 192.168.1.0/24 -o tun0 -j MASQUERADE
COMMIT
In /etc/default/ufw
DEFAULT_FORWARD_POLICY="ACCEPT"
I can access http://192.168.1.3:8701 directly, but I cannot access http://192.168.1.2:8107
So, what am I doing wrong?