1

Consider the following scenario where I have n number of RPis connected to a Ethernet switch in order to create a internal network. All these RPis have a static IP.

Now one of the RPi (call it a head node if you like) has a USB to Ethernet adapter which connects the head node to a router. I have other PCs connected to this router and I want to ssh to the nodes from that PCs.

RPi cluster network

All these RPis have Arch Linux ARM as OS.

How should I configure the network?

itheo92
  • 11
  • 1
  • You want the other pi's to use 192.168.1.1 as their default route and you want pi_0 to IP forward, NAT, and masquerade packets from (and to) them through to/from the router. – goldilocks Aug 28 '16 at 17:36
  • 1
    Let's assume the rpi network uses the subnet 192.168.1.0/24. As long as the external network uses another subnet (e.g. 10.0.0.0/24) it's sufficient to set the default route of all pi's to 192.168.1.1 and define a static route in the router to the 192.168.1.0/24 subnet via the IP the head node has in the 10.0.0.0/24 subnet (e.g. 10.0.1.1). All other pc's have the default route set to the router who then will route all requests to the rpi's to the head node which forwards the request. – framp Aug 28 '16 at 20:25
  • Follow this. Assume that the internal network is the LAN and your main network is the WAN. – Aloha Aug 29 '16 at 03:12
  • Pi_0 as a simple router is sufficient and there is no natting and masquerading required. It will work also this way but introduces additional configuration complexity and requires additional iptables definitions to be able to initiate network connections to the natted devices. – framp Aug 30 '16 at 20:34

1 Answers1

2

Assuming pi_0 has IP 10.0.1.1 on the external network and www is the connection to the internet.

Just enable routing (add net.ipv4.ip_forward=1 in /etc/sysctl.conf) on pi_0, define a static route on the router to the pi_n subnet (route add -net 192.168.1.0/24 gw 10.0.1.1) and set the default gateway to pi_0 on all pi_n (route add default gw 192.168.1.1 eth1 ).

framp
  • 910
  • 7
  • 17