Ein altes Tutorial verwendet wpa-roam in /etc/network/interfaces, andere sagen wpa-conf. Welches denn?
Von English mit KI übersetzt ·
Wieder eine Netzwerkfrage von mir, Entschuldigung. Unsere Forschungsgruppe hat einen Pi 3 Sensorknoten (Bodenfeuchte + Lufttemperatur), der zwischen dem Labor und einer Feldparzelle hin- und hergetragen wird. Er muss sich im Labor mit „LAB-WIFI“ verbinden und auf der Parzelle mit einem 4G-Hotspot („FIELD-AP“) und dabei weiterhin an Hermetry melden, egal wo er sich befindet.
Das Image ist alt (Buster, von einem früheren Studenten übernommen) und verwendet ifupdown. Die Hälfte der Tutorials hat:
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
Die andere Hälfte hat iface wlan0 inet dhcp mit wpa-conf. Die aktuelle Datei hat wpa-roam, und der Knoten hängt manchmal am FIELD-AP ohne jegliche IP-Adresse, bis jemand ihn neu startet. Was ist der tatsächliche Unterschied zwischen beiden, und welchen sollte ich für zwei Netzwerke verwenden?
Another networking one from me, sorry. Our research group has a Pi 3 sensor node (soil moisture + air temp) that gets carried between the lab and a field plot. It needs to join „LAB-WIFI“ in the lab and a 4G hotspot („FIELD-AP“) at the plot, and keep reporting to Hermetry wherever it is.
The image is old (Buster, inherited from a previous student) and uses ifupdown. Half the tutorials have
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
and the other half have iface wlan0 inet dhcp with wpa-conf. The current file has wpa-roam and the node sometimes sits on the field AP with no IP address at all until someone power-cycles it. What is the actual difference between the two, and which should I use for two networks?
Von English mit KI übersetzt ·
Zuerst eine Frage: Ist ein Umstieg auf Bookworm eine Option? NetworkManager macht diese ganze Frage überflüssig.
Before anything: is moving it to Bookworm an option? NetworkManager makes this whole question go away.
Von English mit KI übersetzt ·
Nicht dieser Begriff, der Treiber für den Bodensensor lässt sich anscheinend nur mit dem alten Kernel bauen.
Not this term, the soil sensor driver only builds on the old kernel apparently.
Von English mit KI übersetzt ·
Wir haben im Feld noch einige davon. Der Unterschied liegt darin, wer DHCP steuert.Bei wpa-conf startet ifupdown wpa_supplicant mit Ihrer Konfiguration und führt danach dhclient auf wlan0 selbst aus. wpa_supplicant wählt ein Netzwerk aus den Blöcken in der Datei, ifupdown kümmert sich nicht darum, welches. Einfach, und ausreichend für „verbinde dich mit dem, der von diesen beiden gerade in Reichweite ist“.Bei wpa-roam läuft wpa_supplicant im Roaming-Modus und ruft bei jeder Verbindung und jeder Trennung wpa_action auf, das dann eine logische Schnittstelle aktiviert. Jeder Netzwerkblock kann eine id_str tragen, die die zu verwendende logische Schnittstelle benennt; alles ohne diese fällt auf iface default zurück. Es ist für unterschiedliche IP-Einstellungen pro Netzwerk gedacht. Der Haken: wpa_action muss die Trennung sehen, um die alte Lease abzubauen. Wenn der Knoten weggetragen wird und der AP in ungünstiger Reihenfolge verschwindet, bleibt man mit einer Assoziation ohne Lease zurück. Das ist Ihr Symptom im Feld.Für zwei DHCP-Netzwerke verwenden Sie wpa-conf und Prioritäten:
# /etc/network/interfaces
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
# /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="LAB-WIFI"
psk="..."
priority=10
}
network={
ssid="FIELD-AP"
psk="..."
priority=5
}
Auf der Hermetry-Seite gilt: Jeder Wechsel zwischen Netzwerken trennt die MQTT-Sitzung. Lassen Sie Ihren Client daher mit Backoff neu verbinden und erneut abonnieren. Wenn der Knoten einen Offline-Alarm hat, setzen Sie seine Open-after-Zeit länger als einen Weg vom Labor zur Parzelle, sonst bekommen Sie bei jeder Fahrt einen.
We still have a few of these in the field. The difference is who drives DHCP.
With wpa-conf, ifupdown starts wpa_supplicant with your config and then runs dhclient on wlan0 itself. wpa_supplicant picks a network from the blocks in the file, ifupdown doesn’t care which one. Simple, and enough for „connect to whichever of these two is around“.
With wpa-roam, wpa_supplicant runs in roaming mode and calls wpa_action on every connect and disconnect, which then brings up a logical interface. Each network block can carry an id_str that names the logical interface to use, and anything without one falls to iface default. It’s meant for different IP settings per network. The catch is that wpa_action must see the disconnect to take the old lease down; when the node is carried away and the AP disappears in a funny order, you end up associated with no lease. That’s your field symptom.
For two DHCP networks use wpa-conf and priorities:
# /etc/network/interfaces
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
# /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="LAB-WIFI"
psk="..."
priority=10
}
network={
ssid="FIELD-AP"
psk="..."
priority=5
}
On the Hermetry side, each move between networks drops the MQTT session, so make your client reconnect with backoff and resubscribe. If the node has an offline alarm, set its open-after time longer than a walk from the lab to the plot or you’ll get one every trip.
Von English mit KI übersetzt ·
Außerdem als zusätzliche Absicherung einen Cron-Job mit ip addr show wlan0 | grep -q inet || systemctl restart networking einrichten. Hat uns mehr als einmal einen Vor-Ort-Termin erspart.
Also put a cron’d ip addr show wlan0 | grep -q inet || systemctl restart networking in as a belt-and-braces. Saved us more than one trip.
Von English mit KI übersetzt ·
Auf wpa-conf mit Prioritäten wie oben umgestellt und den Weg hin und zurück zweimal durchgeführt; jedes Mal bekam es innerhalb von etwa 20 s eine Lease, Hermetry zeigte die Lücke und danach neue Messwerte. Den Offline-Alarm habe ich ebenfalls auf 30 Minuten erhöht, der Weg dauert 15. Danke!
Swapped to wpa-conf with priorities like above and carried it out and back twice, it picked up a lease each time within about 20 s and Hermetry showed the gap and then fresh readings. Raised the offline alarm to 30 minutes too, the walk is 15. Thanks!
- Du musst angemeldet sein, um auf dieses Thema antworten zu können.
Mitdiskutieren
Melde dich an, um Fragen zu stellen und zu beantworten, hilfreiche Beiträge mit „Gefällt mir“ zu markieren und die Antwort zu kennzeichnen, die dein Problem gelöst hat. Jeder Beitrag bringt Punkte und Stufen.

