-1

I have a private network with a PC and 3 raspberries.

PC--RPi1--RPi2--RPi3
  • PC: 192.168.0.101/24 (ssh to RPi1)
  • RPi1: 192.168.0.102/24 (eth0 linked to PC) && 192.168.0.103/24 (eth1 linked to Rpi2)
  • Rpi2: 192.168.0.104/24 (eth0 linked to Rpi1) && 192.168.0.105/24 (eth1 linked to Rpi3)
  • RPi3: 192.168.0.106/24 (eth0 linked to Rpi2)

I want to send a message from RPi1 to RPi3. It doesn't work

Should I change the route table? And how?

New contributor
user940969 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • What subnet masks (e.g. 255.0.0.0) or prefix lengths (e.g. /16) are configured for each address on each interface that you've listed? Are you trying to make one large subnet or several? – grawity Jan 11 at 13:49
  • the corresponding subnet is 255.255.255.0 :) – user940969 Jan 11 at 13:50
2

So first of all, this isn't how regular IP routing and subnets work.

Routers generally sit between networks (subnets). They connect multiple networks together – one interface belongs to subnet A, another belongs to subnet B. They forward IP packets, but not Ethernet frames (indeed they might connect networks that aren't Ethernet-like at all).

(For example, the connection PC–RPi1 would use addresses from 192.168.0.0/24, while the connection RPi1–RPi2 would use 192.168.1.0/24, and so on.)

Your configuration expects the opposite. You've configured all interfaces on devices to be in the same subnet, which has two problems:

  1. All devices expect the rest to be reachable directly at Ethernet level (because the subnet mask tells them so), but in reality they aren't: for example, PC and RPi2 are separated by a router (RPi1). When the PC sends an ARP query (broadcast), that query will not go through routers. If the PC sends an Ethernet frame directly to RPi2's MAC address, it also will not reach anything, because RPi2 is not on the same ethernet.

  2. The devices which have multiple interfaces configured for the same subnet don't magically know which address is reachable through which interface. For example, when RPi2 wants to send a packet to 192.168.0.102, it needs to choose between two conflicting routes: "192.168.0.0/24 on eth0" and "192.168.0.0/24 on eth1". How will it know which route to use?

If you must use a single subnet, then a "chain" like this can be made to work in two ways:

  • You can add an individual host route for every single device, on every single device. (For example, RPi2 would have a route to the PC, a route to RPi1, and a route to RPi3.) This quickly results in large amounts of routes, so it's best automated using routing protocols such as Babel or OSPF.

    This method works best when all interfaces are configured as /32's (i.e. netmask 255.255.255.255) so that they don't assume everyone is in a subnet.

  • You can bridge the interfaces instead of routing between them. At IP level, a bridge acts like a single interface (single IP address, etc.) with several "outputs", and will forward all Ethernet frames between them exactly like an Ethernet switch/hub. So after you create a br0 on RPi1/2 and put both eth0 and eth1 in it, then both interfaces will create a single large subnet.

Your Answer

user940969 is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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