I'm having a networking problem connecting to my raspberry pi from the internet through the router. These are the facts and things that I have tried:

  1. My raspberry pi is connected by both wlan0 and eth0 and both have internet addresses assigned by the router through DHCP.
  2. From within my network I can connect without any problems to both the wlan0 and the eth0 addresses by ssh, e.g. from my laptop.
  3. The raspberry pi can connect to the internet without any problem through both eth0 and wlan0.
  4. When setting up portforwarding in my router to the raspberry pi to the eth0 address, I can connect from the internet to my raspberry pi.
  5. When setting up portforwarding in my router to the wlan0 address, connections timeout!
  6. Setting up portforwarding to other another computer's wifi connections work without any problem. E.g. portforwarding of ssh to my laptop works fine.
  7. I have not setup a firewall but are using the default values from the installation.

I tried switching wifi dongles, but the behavior is the same for two different dongles with different chipsets.

My system configuration on the raspberry pi is:

> cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION="9 (stretch)"

So what is going on? How came the wifi interface is blocking incoming connections from the router?

Update 1: Portforwarding of https through the wlan0 interface works! Thus the problem must be with the sshd configuration.

  • You mentioned it works with https and there should be an issue with the sshd config. How do you test access to your local network? Whats the output of sudo netstat -ltpn on your Raspberry? – framp Jan 4 '19 at 22:03
  • Have you tried running an external nmap service against your WAN address to confirm that port 22 can be opened on the gateway? e.g. hackertarget.com/nmap-online-port-scanner – Roger Jones Mar 27 '19 at 17:03
  • It's not clear that the wlan0 address is blocking connections. With 2 possible routes to back to the client it is equally possible that the response is being returned via the Eth0 interface - however this won't be accepted as a valid response, and may also be blocked by the router. Check the routing tables on the RPi to see which is the preferred route. A simple test would be to disconnect Eth0 and try the connection. – Charemer Oct 2 '19 at 8:21

Have you checked your /etc/ssh/sshd_config regarding to the ListenAddress?

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
Protocol 2
| improve this answer | |
  • I haven't edited the sshd_config file. The only non-comment options are ChallangeResponseAuthentication, UsePAM, X11Forwarding, PrintMotd, AcceptEnv, and Subsystem sftp`. Nothing appears related to the timeout problem. – Dov Grobgeld Jan 24 '18 at 21:00
  • have you tried to remove the ethernet cable, so that you are only connected via wlan0 to your router? are you than able to connect to your pi? - you might want to have a look at + his answer: raspberrypi.stackexchange.com/questions/52098/… – AlexOnLinux Jan 24 '18 at 21:49

I had a problem that was (I think) similiar to this one. try making sure the date/time on your raspberry pi and remote computer are both correct. Also, when setting up port forwarding, make sure you choose to forward the right port(the default for ssh is 22).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.