Von English mit KI übersetzt ·
Genau das hatten wir an einem unserer Standorte, nachdem der ISP IPv6 aktiviert hat. Der Pi bekommt eine IPv6-Adresse, versucht sie zuerst, die Route ist kaputt und er wartet bis zum Timeout, bevor er auf IPv4 zurückfällt. Dein curl-Test zeigt das.Ich wollte IPv6 nicht überall deaktivieren, also habe ich dem Pi gesagt, dass er IPv4 bevorzugen soll. Entkommentiere diese Zeile in /etc/gai.conf:
precedence ::ffff:0:0/96 100
Ein Neustart ist für neue Prozesse nicht nötig, starte einfach dein Skript neu. Wenn du es nur für das Skript willst, kannst du es in Python vor dem Import von requests erzwingen:
import socket
import urllib3.util.connection as conn
conn.allowed_gai_family = lambda: socket.AF_INET
Owens Idee ist für später trotzdem gut. Trag die öffentliche IPv4 des Hotels in die IP-Allowlist des Schlüssels ein, damit ein gestohlener Schlüssel anderswo nutzlos ist.
Had exactly this at one of our properties after the ISP turned IPv6 on. The Pi gets an IPv6 address, tries it first, the route is broken and it waits for the timeout before falling back to IPv4. Your curl test shows that.
I didn’t want to switch IPv6 off for everything, so I told the Pi to prefer IPv4. Uncomment this line in /etc/gai.conf:
precedence ::ffff:0:0/96 100
No reboot needed for new processes, just restart your script. If you only want it for the script, you can force it in Python before importing requests:
import socket
import urllib3.util.connection as conn
conn.allowed_gai_family = lambda: socket.AF_INET
And Owen’s idea is still a good one for later. Put the hotel’s public IPv4 in the key’s IP allowlist so a stolen key is useless elsewhere.

