Hi All,
I'm trying to port forward from my VPN to my Router and back again. I'm pretty sure that this is the issue I'm having as everything else is working properly. The server I'm port forwarding to is an nginx server 10.0.4.246 but this doesn't really matter as it's just sending and receiving data I believe.
Nginx Snippet:
location / {
proxy_pass http://172.16.1.176:1234;
proxy_connect_timeout 820s;
proxy_send_timeout 820s;
proxy_read_timeout 820s;
client_max_body_size 512M;
}
Whenever I try to go to a domain name after using the rules below they either route me back to the Router IP of 172.16.1.1 or take me to an error page (unable to load). I'm very stumped and It's 3:00AM. Any help would be appreciated.
Here are my wireguard rules:
PreUp = sysctl -w net.ipv4.conf.all.forwarding=1
PostUp = iptables -I INPUT -p udp --dport 51821 -j ACCEPT
PostUp = iptables -I FORWARD -i ens3 -o wg0 -j ACCEPT
PostUp = iptables -I FORWARD -i wg0 -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o ens3 -j MASQUERADE
PostUp = iptables -t nat -A POSTROUTING -o wg0 -j MASQUERADE
PostUp = ip6tables -I FORWARD -i wg0 -j ACCEPT
PostUp = ip6tables -t nat -A POSTROUTING -o ens3 -j MASQUERADE
#PostUp = iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 80 -j DNAT --to-destination 10.10.20.3:80
#PostUp = iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 443 -j DNAT --to-destination 10.10.20.3:443
PostUp = iptables -t nat -I PREROUTING -i ens3 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.10.20.3:80
PostUp = iptables -t nat -I PREROUTING -i ens3 -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.10.20.3:443
PostUp = iptables -t nat -I PREROUTING -i ens3 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.4.1:80
PostUp = iptables -t nat -I PREROUTING -i ens3 -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.0.4.1:443
PostDown = iptables -D INPUT -p udp --dport 51821 -j ACCEPT
PostDown = iptables -D FORWARD -i ens3 -o wg0 -j ACCEPT
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o ens3 -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -o wg0 -j MASQUERADE
PostDown = ip6tables -D FORWARD -i wg0 -j ACCEPT
PostDown = ip6tables -t nat -D POSTROUTING -o ens3 -j MASQUERADE
#PostDown = iptables -t nat -D PREROUTING -i ens3 -p tcp --dport 80 -j DNAT --to-destination 10.10.20.3:80
#PostDown = iptables -t nat -D PREROUTING -i ens3 -p tcp --dport 443 -j DNAT --to-destination 10.10.20.3:443
PostDown = iptables -t nat -D PREROUTING -i ens3 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.10.20.3:80
PostDown = iptables -t nat -D PREROUTING -i ens3 -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.10.20.3:443
PostDown = iptables -t nat -D PREROUTING -i ens3 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.4.1:80
PostDown = iptables -t nat -D PREROUTING -i ens3 -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.0.4.1:443
I included both 10.10.20.3 and 10.0.4.1 for testing purposes but I couldn't get them to work.
Here are the port forwarding rules I have tried:
config redirect
option dest 'vpnlan'
option target 'DNAT'
option src 'vpnlan'
option src_dport '80'
option dest_ip '10.0.4.246'
option dest_port '80'
option src_ip '10.10.20.3'
config redirect
option dest 'vpnlan'
option target 'DNAT'
option src 'vpnlan'
option src_dport '443'
option dest_ip '10.0.4.246'
option dest_port '443'
option src_ip '10.10.20.3'
10.0.4.246
This is the response I get from my 10.0.4.246 server:
root@nginx:~# netstat -tuln | grep -E '80|443'
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN
root@nginx:~#
10.0.4.246
It looks to be working but whenever I try to curl my domain name:
curl https://panel.example.com
curl: (7) Failed to connect to panel.example.com port 443 after 89 ms: Couldn't connect to server
root@nginx:~#
I have it behind an NGINX server but the local IP's are all available and I'm able to access all the local ports as well.
10.0.4.246
Same Server example:
root@nginx:~# curl http://172.16.1.176:1234/
<html>
<title>BlueBubbles Server</title>
<body>
<h4>Welcome to the BlueBubbles Server landing page!</h4>
</body>
</html>
root@nginx:~#
10.0.4.246
Here is my IP address coming back on the same server, this is my VPN IP address. (this has been changed for security purposes):
root@nginx:~# curl ipecho.net/plain; echo
45.40.20.110
root@nginx:~#
Finally a screenshot of my interfaces. I'm only worried about the zones in blue.