1

I recently set up my Raspberry Pi to act as a router. All is working well when it comes to connected devices accessing the internet. The problem is that my computers don't seem to be allowed/capable of communicating with each other.

Device map:

  • Router Pi (a Raspberry Pi 4, set up as a router)
  • Computer Pi (a Raspberry Pi 3)
  • Desktop Computer (a desktop computer running Linux)

Both the Computer Pi and the Desktop Computer is connected to Router Pi over WiFi.

For example, when trying to open ssh between Desktop Computer and Computer Pi, i receive the following message:

ssh user@192.168.4.4
ssh: connect to host 192.168.4.4 port 22: No route to host

However, the following works:

  • ssh to Router Pi from Desktop Computer.
  • ssh to Computer Pi from Router Pi

This is the output of my iptables configuration, since I suspect it might have to do with this. Here I also tried to allow ssh connections by adding a rule, but it doesn't seem to have affected anything.

sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        

So, to the question: What could prohibit the devices from accessing one another?

EDIT: The tutorial i used to set up the router pi is this one: https://www.raspberrypi.org/documentation/configuration/wireless/access-point-routed.md

4
  • Following the setup you have used there are devices direct connected to the internet router (PC#1 and PC#2) and one device connected to the RasPi by WiFi (Laptop). Where are your Desktop Computer and Computer Pi connected? Both by WiFi to the Router Pi? – Ingo Dec 14 '20 at 18:40
  • Correct. Both devices are connected over WiFi to the Router Pi. – Rydberg1995 Dec 14 '20 at 18:43
  • Please add this important information to the question. – Ingo Dec 14 '20 at 18:50
  • 1
    Thanks, I've done that now. – Rydberg1995 Dec 14 '20 at 18:52
1

Because Computer Pi and Desktop Computer are both connected to the Router Pi by WiFi they share the same subnet, I assume 192.168.4.0/24. So they should be able to connect to each other out of the box. I'm not an expert in using iptables but as far as I understand, the connected devices do not only want to connect to the Router Pi (INPUT). ssh from and to the Router Pi works. The other devices want to connect to each other. So the iptables rule should not be only on the INPUT chain, it should also be on the FORWARD chain. To verify that routing is working properly you should remove the rule temporary and ping all devices from any device.

0

You Rpi-4 is acting as a router, so all devices behind the router, the RPi, are presenting the IPv4 address of 10.0.0.4 to the outside. The inside ipv4 is your 192.168.4.1/24 range.

You need a port forwarding statement in your iptables "firewall" of:

`-A PREROUTING -i eth0 -p tcp -m tcp --dport 22 -j DNAT --to-destination 192.168.4.2'

Three things to try. 1) mainly for my edification, is to run "nft list ruleset". I have a RPi-4 as my main household router. My firewall is written in iptables but it is being translated into nftables (magically somehow)!

  1. from another 10.0.0.x computer can you ssh into 10.0.0.2, the RPi router?

and 3) buy a $10 USB to Ethernet dongle off of Amazon (or someplace). And setup a real router with dnsmasq for the dhcp server. Add a good router firewall.

A real router/firewall should not use the same Ethernet/Wifi port to communicate. Too easy to snoop on the same wifi SSID.

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.