From 3ee160b4cfca78584dd87f429deb55f4009b5fd4 Mon Sep 17 00:00:00 2001 From: CamDavidsonPilon Date: Thu, 6 Jun 2024 15:30:55 -0400 Subject: [PATCH] adding networking --- .../20-User interface/01-introduction.md | 2 +- user-guide/30-Advanced/05-networking.md | 105 ++++++++++++++++++ .../Networking troubleshooting.md | 6 +- user-guide/99-common-questions.mdx | 11 +- 4 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 user-guide/30-Advanced/05-networking.md diff --git a/developer-guide/20-User interface/01-introduction.md b/developer-guide/20-User interface/01-introduction.md index 7537c9212..115672353 100644 --- a/developer-guide/20-User interface/01-introduction.md +++ b/developer-guide/20-User interface/01-introduction.md @@ -12,7 +12,7 @@ The web server we use is lighttpd, and hosted from `/var/www/pioreactorui`. This The lighttpd conf file is located in `/etc/lighttpd/conf-enabled/50-pioreactorui.conf`. Error logs (though not helpful) are in `/var/log/lighttpd/error.log`. -The default protocol is `http` served on port `80`. To use `https` requires a certificate, and is out of scope for this project. If you'd change the protocol or the port, you'll need up tell the software too: look in the config.ini under `[ui]` section. +The default protocol is `http` served on port `80`. To use `https` requires a certificate, and is out of scope for this project. If you'd change the protocol or the port, you'll need up tell the software too: look in the config.ini under `[ui]` section. [How to change the web UI port](/user-guide/networking#changing-web-ui-port-from-80-to-something-else) ### Backend diff --git a/user-guide/30-Advanced/05-networking.md b/user-guide/30-Advanced/05-networking.md new file mode 100644 index 000000000..c0482acdb --- /dev/null +++ b/user-guide/30-Advanced/05-networking.md @@ -0,0 +1,105 @@ +--- +title: Networking +slug: /networking +--- + +:::info +Previously, Raspberry Pis used a file called `wpa_supplicant.conf` to handle wifi network connections. **This is not longer the case**. Modern Raspberry Pi software, including the Pioreactor, doesn't use `wpa_supplicant.conf` at all. Instead, the tool `nmcli` replaces it. Don't follow tutorials that use `wpa_supplicant.conf`. +::: + + +## General networking tools + +### Connecting to a wifi network using `nmcli` + + +You can first discover all the visible networks with: + +``` +sudo nmcli d wifi list +``` + +If you see your network on the list, then run: + + +``` +sudo nmcli device wifi connect password ifname wlan0 +``` + +(If you get a "Can't find" error, try running the above `list` command again.) + +### Connecting to multiple networks + +First, some terminology and understanding for us: a computer, like a Pi, has networking interfaces. For example, the onboard wifi on RPi’s is one such interface. The larger, model Bs, have an ethernet connector, which is another interface. Each interface can connect to 0 or 1 networks. + +In order to connect to multiple networks, you need a Raspberry Pi with multiple interfaces. You can add interfaces with devices like a [USB wifi device](https://forum.pioreactor.com/t/connecting-more-workers-to-cluster/330/3). + +To see what your current interfaces are doing, use: +``` +nmcli device +``` + +The right hand side shows your connected interfaces. For example, if have a ethernet connection to a router, you'll see an `eth0` connection active. If you have an additional wifi hardware device attached to your Pi, you'll see `wlan1`. + +---- + +To connect to another wifi network using `wlan1`, use: + +``` +sudo nmcli device wifi connect password ifname wlan1 +``` + +---- + +If your leader is connected to multiple networks `A` and `B`, and you access the UI over network `A`, but your workers access over network `B`, the leader is in the position called a "gateway". You'll need to make some configuration changes to your cluster. Since the leader is attached to networks `A` and `B`, it has two IPs (use `hostname -I` to see all the ips), let's call them `ipA` and `ipB` respectively. + +1. Access the configuration in the UI. +2. In the _shared_ config.ini, edit the `[mqtt]` `broker` field to be equal to `ipA`. Also edit the `leader_address` to be `ipB`. +3. In each of the workers (including the leader's config.ini, if it's a worker), add the following: + ``` + [mqtt] + broker=ipB + ``` + +You may need to restart your cluster for these to take full effect. + + + +### Starting the [Pioreactor local access](/user-guide/local-access-point) point using `nmcli` + +Note that you can only have 1 network connection for each network interface. So if you have only 1 wifi device (by default, RPi's only have 1 wifi device on them -> only 1 wifi interface), the following will replace any existing wifi connection. + +``` +sudo nmcli con up PioreactorAP +``` + + +#### Setting `leader_address` and MQTT `broker` in your config.ini + + +### Changing web UI port from `80` to something else + +To change the web UI port from the default of `80`, following these instructions: + +1. SSH into your leader Pioreactor. +2. We'll edit the lighttpd configuration first: + ``` + sudo nano /etc/lighttpd/lighttpd.conf + ``` + + and find the line starting with `server.port`. Change this to something else (preferably not a value below 1024). Save and exit. + +3. Restart lighttpd with: + ``` + sudo systemctl restart lighttpd.service + ``` + You should be able to access the web UI only on http://`leader name`:`new port`, for example: http://leader.local:8080 + +4. In your configuration, under the `[ui]` section, change the `port` option from `80` to your new port value. Save. You may need to restart your cluster for this new port to propagate to all machines correctly. + + +## Connecting to eduroam + +This is a work-in-progress, but here's [one example](https://forum.pioreactor.com/t/connecting-more-workers-to-cluster/330/3#connecting-to-eduroam-2). + + diff --git a/user-guide/50-Troubleshooting/Networking troubleshooting.md b/user-guide/50-Troubleshooting/Networking troubleshooting.md index aa65d2989..8dbd10e1a 100644 --- a/user-guide/50-Troubleshooting/Networking troubleshooting.md +++ b/user-guide/50-Troubleshooting/Networking troubleshooting.md @@ -7,12 +7,16 @@ slug: /troubleshooting-networks It is possible that your mDNS is being blocked or restricted. If possible, log into your router and enable settings that allow "multicast", or "mDNS", or "IGMP proxing". If you are using a the builtin [local access point](/user-guide/local-access-point), this solution is not the correct one. -Also, if you are able to provide a permanent IPv4 address to your leader, you can get a significant performance boost by setting the configuration parameter `leader_address` in section `[cluster.topology]` to the IPv4 address. +Also, if you are able to provide a permanent IPv4 address to your leader, you can get a significant performance boost by setting the configuration some config parameters to the IPv4 address. ``` [cluster.topology] # below is an example, your IPv4 may differ: leader_address=192.168.0.3 + +[mqtt] +broker_address=192.168.0.3 + ``` ### I'm having trouble with the local access point diff --git a/user-guide/99-common-questions.mdx b/user-guide/99-common-questions.mdx index 8c3ca40f4..6ef4ebb7b 100644 --- a/user-guide/99-common-questions.mdx +++ b/user-guide/99-common-questions.mdx @@ -134,13 +134,14 @@ If the standard mixing and aeration with the stir bar is not enough for your app Raspberry Pi Hardware --------------------- -#### What Raspberry Pi hardware can I use? I see Raspberry Pi 1, 2, 3, 4, A, B, +, Zero - it's confusing! +#### What Raspberry Pi hardware can I use? I see Raspberry Pi 1, 2, 3, 4, 5, A, B, +, Zero - it's confusing! We've designed the hardware and software to be compatible with any Raspberry Pi that has onboard Wifi and a 40 pin header. That includes (at the time of writing): * Raspberry Pi 3 Model B & B+ * Raspberry Pi 3 Model A+ * Raspberry Pi 4 Model B ³ +* Raspberry Pi 5 Model B * Raspberry Pi Zero W (with header) ¹ * Raspberry Pi Zero 2 W (with header) * Raspberry Pi 400 ² @@ -224,9 +225,13 @@ Unfortunately, the microSD card becoming corrupted or damaged is an infrequent b Networking --------------------------------- -#### Can I use Ethernet cable connections instead of WIFI connections? +#### How do I change/edit the network the Pioreactor on? -Yes, so long as the Raspberry Pi's are connected to the same network and discoverable, this should work. Even mixing Ethernet and WIFI is fine. +With modern Raspberry Pis, + +#### Can I use Ethernet cable connections instead of Wifi connections? + +Yes, so long as the Raspberry Pi's are connected to the same network and discoverable, this should work. Even mixing Ethernet and Wifi is fine. #### How can I determine the Pioreactor's IP address? Or the MAC address?