sdelrio / rpi-hostap

Transform your PI into a Wireless Router (DHCP and WPA2 already insisde)
76 stars 65 forks source link

Setting up internet access on Raspberrypi4 #15

Open maryum375 opened 4 years ago

maryum375 commented 4 years ago

Hi, I encountered this project looking for a way to setup my raspberrypi 4 as a wireless router for my iot devices. I pulled and started the container using: $ sudo docker run -d -t -e INTERFACE=wlan0 -e CHANNEL=6 -e SSID=RanIOT1 -e AP_ADDR=192.168.4.1 -e SUBNET=192.168.4.0 -e WPA_PASSPHRASE=passw0rd --privileged --net host sdelrio/rpi-hostap:latest

And it seems to open the wireless hotspot. The thing is that this hotspot is not connected to the internet. what did I do wrong? This is the log of the container:

NAT settings ip_dynaddr, ip_forward ip_dynaddr already 1 ip_forward already 1 1 1 Setting iptables for outgoing traffics on all interfaces... Configuring DHCP server .. Starting DHCP server .. Internet Systems Consortium DHCP Server 4.3.3-P1 Copyright 2004-2016 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Config file: /etc/dhcpd.conf Database file: /var/lib/dhcp/dhcpd.leases PID file: /var/run/dhcp/dhcpd.pid Wrote 1 leases to leases file. Listening on LPF/wlan0/dc:a6:32:37:82:fe/192.168.4.0/24 Sending on LPF/wlan0/dc:a6:32:37:82:fe/192.168.4.0/24 Sending on Socket/fallback/fallback-net Starting HostAP daemon ... Configuration file: /etc/hostapd.conf wlan0: Could not connect to kernel driver Using interface wlan0 with hwaddr dc:a6:32:37:82:fe and ssid "RanIOT1" wlan0: interface state UNINITIALIZED->ENABLED wlan0: AP-ENABLED wlan0: STA 7c:d6:61:f8:49:eb IEEE 802.11: associated wlan0: AP-STA-CONNECTED 7c:d6:61:f8:49:eb wlan0: STA 7c:d6:61:f8:49:eb RADIUS: starting accounting session 5EA89028-00000000 wlan0: STA 7c:d6:61:f8:49:eb WPA: pairwise key handshake completed (RSN) wlan0: STA 7c:d6:61:f8:49:eb WPA: group key handshake completed (RSN) wlan0: STA 7c:d6:61:f8:49:eb RADIUS: starting accounting session 5EA89028-00000000 wlan0: STA 7c:d6:61:f8:49:eb WPA: pairwise key handshake completed (RSN) wlan0: STA 7c:d6:61:f8:49:eb IEEE 802.11: disassociated wlan0: AP-STA-DISCONNECTED 7c:d6:61:f8:49:eb wlan0: STA 7c:d6:61:f8:49:eb IEEE 802.11: disassociated wlan0: STA 7c:d6:61:f8:49:eb IEEE 802.11: associated wlan0: AP-STA-CONNECTED 7c:d6:61:f8:49:eb wlan0: STA 7c:d6:61:f8:49:eb RADIUS: starting accounting session 5EA89028-00000001 wlan0: STA 7c:d6:61:f8:49:eb WPA: pairwise key handshake completed (RSN) wlan0: STA 7c:d6:61:f8:49:eb WPA: group key handshake completed (RSN) wlan0: STA 7c:d6:61:f8:49:eb RADIUS: starting accounting session 5EA89028-00000001 wlan0: STA 7c:d6:61:f8:49:eb WPA: pairwise key handshake completed (RSN) wlan0: STA 7c:d6:61:f8:49:eb IEEE 802.11: disassociated wlan0: AP-STA-DISCONNECTED 7c:d6:61:f8:49:eb wlan0: STA 7c:d6:61:f8:49:eb IEEE 802.11: disassociated wlan0: STA 7c:d6:61:f8:49:eb IEEE 802.11: disassociated wlan0: STA 7c:d6:61:f8:49:eb IEEE 802.11: disassociated

Thanks a lot for your help!

sdelrio commented 4 years ago

Doesn't seem you set OUTGOINGS env variables, look at README.md example and set up that. By thefault this set is disabled if you don't set

OUTGOINGS | false | Interfaces to external traffic
mebitek commented 1 year ago

I run as readme file says but I'm haven't internet connection too sudo docker run -d -t -e INTERFACE=wlan0 -e CHANNEL=6 -e SSID=runssid -e AP_ADDR=192.168.254.1 -e SUBNET=192.168.254.0 -e WPA_PASSPHRASE=passw0rd -e OUTGOINGS=eth0 --privileged --net host sdelrio/rpi-hostap:latest also when I run it I get on my raspberry pi 4:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

sdelrio commented 1 year ago

The image is from +5 years ago, and docker probably added some extra check for the image which was not set before and was using amd64 by default even if it was arm image. Added build-multiarch: in the Makefile buildx for multiarch image and pushed a new tag 0.31 to the dockerhub. Now the image should be valid for:

linux/amd64 linux/arm/v7 linux/arm64

ledowong commented 11 months ago

same, no internet connection

fex95 commented 5 months ago

I had the same problem on a Pi4 with Raspian 6.1.0-rpi8-rpi-v8 and was able to fix it by enabling the flags net.ipv4.ip_forward=1 and net.ipv6.conf.all.forwarding=1 on the host /etc/sysctl.conf to allow forwarding.


sudo nano /etc/sysctl.conf #net.ipv4.ip_forward=1 -> net.ipv4.ip_forward=1 #net.ipv6.conf.all.forwarding=1 -> net.ipv6.conf.all.forwarding=1