jordanthompson
Posts: 6
Joined: Wed Jul 29, 2015 2:51 pm

port forwarding not working

Mon Jun 17, 2019 1:35 pm

I have a raspberry pi on network behind an openwrt router. The router's wan is public.
The router is port-forwarding:
xxxx from the wan to 80 on the pi
yyyy from the wan to 443 on the pi
zzzz from the wan to 22 on the pi
my web server uses secure http, so http (port 80) is set up to forward to https (port 443)

Everything was working fine; I could access my web page by:
http://my.domain.com and it would forward to https://my.domain.com
pi:80 would forward to https://my.domain.com
pi:443 would forward to https://my.domain.com
sftp to my.domain.com:zzzz would forward to py:22

I recently changed my internet from 192.168.1.1/255.255.255.0 to 10.13.0.1/255.255.252.0
And now it is not working:
http://my.domain.com times out
pi:80 forwards to https://my.domain.com, but then it times out
sftp to my.domain.com:zzzz, it times out

I changed my port forwarding:
zzzz from the wan to 22 on a nas
now
sftp to my.domain.com:zzz forwards correctly to nas:22

so the problem lies with the raspberry pi... I think there may be an artifact from the 192.168.1.1/255.255.255.0 network laying around on the pi somewhere.
Any suggestions?

epoch1970
Posts: 3085
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: port forwarding not working

Mon Jun 17, 2019 2:03 pm

Port forwarding just does not care about the IP config, as long as it is correct.

I suggest you use ipcalc to check your configs on the router and the Pi. You can install it on the Pi or use one online
http://jodies.de/ipcalc?host=10.13.0.1&mask1=22&mask2=

Then check the usual suspects on the Pi, /etc/hosts/ /etc/dhcpcd.conf /etc/network/interfaces, /etc/resolv.conf, /etc/rc.local, iptables rules, ...
Also verify the router's firewall rules are up to date. Outgoing 22/tcp might be working but others failing.

(Prefer using DHCP for the LAN with IP address reservations; it makes network provisioning/maintenance easier.)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Networking and servers”