docker-arm
docker-arm copied to clipboard
RPi Zero access RPi 3 L2 Network with OTG
Is it possible to make the RPi Zeros access the RPi 3 network an get an IP address on that network. Assuming all my RPi Zeros are using the OTG network and connected to RPi 3 via USB.
I think I can use something link bridge but didn't tested it yet.
I just mounter my first setup (1 RPi 3 + 4 RPi Zero ), but I'm planning to make other similar setups.
If the RPi Zero is only acessible inside the RPi 3 network, it woldn't be possible to manage all theses RPi Zero workers in a swarm composed of two or more of these kits.
Did you get the point ?
I'll do some tests soon, when I get the module for ethernet and serial to work simultaneously so I can still access the RPi Zeros even if I lose network access. ;)
Hi @endersonmaia sorry I missed this issue. How far did you get?
It's possible for the Zeros to maintain their own subnet but to access machines on the outer network in both directions through IPv4 forwarding.
@endersonmaia, I have done something similar, allowing all of the pi's to acquire DHCP addresses from the router.
Instead of assigning static IP's and using iptables
, add the following:
sudo apt-get update
sudo apt-get install bridge-utils
Add the following to /etc/network/interfaces
:
allow-hotplug eth1
auto eth1
iface eth1 inet manual
pre-up brctl addif br0 eth1
allow-hotplug eth2
auto eth2
iface eth2 inet manual
pre-up brctl addif br0 eth2
allow-hotplug eth3
auto eth3
iface eth3 inet manual
pre-up brctl addif br0 eth3
allow-hotplug eth4
auto eth4
iface eth4 inet manual
pre-up brctl addif br0 eth4
allow-hotplug usb0
auto usb0
iface usb0 inet manual
pre-up brctl addif br0 usb0
allow-hotplug usb1
auto usb1
iface usb1 inet manual
pre-up brctl addif br0 usb1
allow-hotplug usb2
auto usb2
iface usb2 inet manual
pre-up brctl addif br0 usb2
allow-hotplug usb3
auto usb3
iface usb3 inet manual
pre-up brctl addif br0 usb3
auto br0
iface br0 inet dhcp
bridge_ports eth0 eth1 eth2 eth3 eth4 usb0 usb1 usb2 usb3
post-up ip link set br0 address 00:22:82:ff:00:00
Add the following to /etc/avahi/avahi-daemon.conf
:
allow-interfaces=br0
The above interfaces
excerpt could probably use some work. For some reason sometimes Pi Zero's appear as usb* instead of the usual eth*. It's probably a bit overkill, but I wrote the interfaces file to handle both cases.
I quite like this configuration because it allows you to SSH directly into the Pi Zero's by hostname and use their hostnames for all aspects of configuration.
(Edited to add the br0 MAC address and Avahi configuration to fix hostname propagation for the host.)
@alexellis haven't done anything yet, let's see if I can get this to work with @fredmon3 did
To be extra clear the steps listed above are to be performed on the host Pi in place of steps 2.0 Configure the host and 2.1 Routing.
You'll also want to skip the Set a static IP address step under 1.0 Prepare your Pi Zeros when configuring the worker Pi's.
@fredmon3 the bridging looks smart (something I'd test eventually) - the udev rules are supposed to hard-code the "interface" name according to the MAC address. Power and USB cables appear to be a factor here too.
I have four raspberry pi zeros in OTG on a clusterhat with a pi3. They are running raspian. Is it possible to install docker swarm?
@CheetahGod I believe people have done that before, but be careful with installing Docker on the host ClusterHAT because it may interfere with the bridge interface used to talk to the zeros. If you configure everything manually with the Raspbian Lite image it will work better.
I am challenged by instructions 2.1. (I should start by saying I am new to iptables.) When I ssh from the host into either of the workers, I cannot ping 8.8.8.8 or other valid ip addresses. I CAN ping these addresses from the host. I would like my workers to have access to the internet. I check my iptables rules on the host as follows (btw - I connect to the internet over wifi):
pi@raspberrypi:~ $ sudo iptables -t nat -L -v
Chain PREROUTING (policy ACCEPT 154 packets, 10492 bytes)
pkts bytes target prot opt in out source destination
2 126 DOCKER all -- any any anywhere anywhere ADDRTYPE match dst-type LOCAL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 60 packets, 7186 bytes)
pkts bytes target prot opt in out source destination
1 60 DOCKER all -- any any anywhere !loopback/8 ADDRTYPE match dst-type LOCAL
Chain POSTROUTING (policy ACCEPT 4 packets, 240 bytes)
pkts bytes target prot opt in out source destination
4 252 MASQUERADE all -- any !docker0 172.17.0.0/16 anywhere
57 7022 MASQUERADE all -- any wlan0 anywhere !10.0.11.0/24
0 0 MASQUERADE all -- any wlan0 anywhere !10.0.12.0/24
0 0 MASQUERADE all -- any wlan0 anywhere !10.0.13.0/24
Chain DOCKER (2 references)
pkts bytes target prot opt in out source destination
0 0 RETURN all -- docker0 any anywhere anywhere
Is this correct? I am not sure what else to check.
Same as @stevebelt.
Can: SSH to Host SSH to Client SSH from Host to Client Ping from Host to Internet
Can't Ping from Client to Internet
sudo iptables -t nat -L -v
Chain PREROUTING (policy ACCEPT 31 packets, 5730 bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 31 packets, 5730 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 9 packets, 648 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
9 648 MASQUERADE all -- any eth0 anywhere !10.0.11.0/24
pi@taskmaster:~ $ ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:0e:98:d1
inet addr:192.168.178.29 Bcast:192.168.178.255 Mask:255.255.255.0
inet6 addr: fe80::9cc0:4bde:a63e:1611/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5409 errors:0 dropped:290 overruns:0 frame:0
TX packets:1319 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1048386 (1023.8 KiB) TX bytes:201556 (196.8 KiB)
ethusb1 Link encap:Ethernet HWaddr 00:22:82:ff:ff:01
inet addr:10.0.11.1 Bcast:10.0.11.255 Mask:255.255.255.0
inet6 addr: fe80::bed1:cc9f:60c4:b8ae/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:846 errors:0 dropped:0 overruns:0 frame:0
TX packets:662 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:115150 (112.4 KiB) TX bytes:56696 (55.3 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:1104 (1.0 KiB) TX bytes:1104 (1.0 KiB)
wlan0 Link encap:Ethernet HWaddr b8:27:eb:5b:cd:84
inet6 addr: fe80::b500:4e83:f100:1942/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
pi@worker1:~ $ ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
usb0 Link encap:Ethernet HWaddr 00:22:82:ff:ff:11
inet addr:10.0.11.2 Bcast:10.0.11.255 Mask:255.255.255.0
inet6 addr: fe80::c02e:7c42:4932:8f6c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:632 errors:0 dropped:0 overruns:0 frame:0
TX packets:818 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:45640 (44.5 KiB) TX bytes:123418 (120.5 KiB)
EDIT: I finally found out I missed to edit ip forwarding in the config file instead of the console so it is reboot save.