I am trying to setup a Raspberry Pi with RaspAP so that a computer can connect to the Pi over its wireless access point, access it through SSH on a static IP address, but also be able to access the internet through the Pi's second WiFi connection with a USB wifi adapter plugged into the Pi. This setup is not working out of the box.
I bought a new Raspberry Pi 4B 8GB, imaged it with Raspberry PI OS 32-bit, and plugged in Edimax 7811Un wireless adapter suggested in RaspAP documentation (also tried Ralink RT5370 on supported list).
After installing updates and setting WiFi Country, I installed RaspAP using instructions at https://raspap.com/ and verified the default setup was working.
RaspAP created a wireless access point on wlan0 (the Raspberry Pi's on-board wlan adapter) and used eth0 (on-board ethernet) to connect to my home network and access the Internet. I was able to connect to RaspAP's wireless access point and access the Internet through internet connection sharing established by RaspAP using dnsmasq and IP forwarding.
Then I went to follow steps in "Can I use wlan0 and wlan1 rather than eth0 for my AP?" (https://docs.raspap.com/faq/). I went to the Hotspot page, changed it to use wlan1 (Edimax), saved settings, and restarted hotspot. When I went to connect to the access point with my computer, it connected successfully, but internet connection sharing didn't work - any attempt to access the internet from the computer connected to Pi's AP just displayed an error saying there was no internet.
I re-installed RaspAP to get back to the original state, and the AP control panel at 10.3.141.1 stopped working. Both wlans stopped being able to connect to the Internet (wlan0 not associated despite wpa_supplicant still having the information needed to connect to my home WiFi, wlan1 has a static IP and not bound). If the ethernet was plugged in, I could still get an Internet connection, but of course the reason I want to set this whole thing up is because I won't have ethernet available in production.
At this point, no matter how many times I re-installed RaspAP I always get into this "broken, cannot reinstall" state and have to re-image the whole SD card and start over. The logs basically said wlan driver failed on startup and hostapd could not start, because it failed to set AP mode (mode 3) on the wlan adapter, giving "device not found" (-19) as the reason even though it was listed as a USB device:
failed to set interface index 3 to mode 3: -19 (not found)
Occasionally, after re-installing and restarting 2-3 times the RaspAP control panel would start working suddenly but say that hostapd is down (and then stop working again on the next restart).
I attempted the following:
- Enabling debug logging for hotspot and DHCP in RaspAP
- Checking raspapd service logs
- Checking hostapd service logs
- Checking dnsmasq service logs
- Checking kernel logs
- Checking system logs
- Replacing the Raspbery Pi official power adapter
- Using an older Raspbian 2019 image
- Re-imaging with Raspberry PI OS 32bit Full and Lite
- Using Edimax 7811Un wireless adapter on RaspAP supported list
- Using Ralink RT5370 wireless adapter on RaspAP supported list
- Using TP-Link TL-WN722N wireless adapter on GitHub wireless repeater supported list
- Using Alfa AWUS036ACHM wireless adapter on GitHub wireless repeater supported list
- Using LB-Link RTL8188CUS wireless adapter on Adafruit supported list, with 2020 and 2019 downgraded drivers
- Setting up the hostapd, wpa_supplicant, dhcpcd, and dnsmasq manually using guides https://github.com/morrownr/8812au/blob/5.9.3.2/Bridged_Wireless_Access_Point.md, https://charlesreid1.com/wiki/RaspberryPi/July_2020, and https://github.com/hydrogeologger/pyduino/wiki/Making-Raspberry-Pi-as-an-internet-Router-(NAT).
I included the system information and logs useful for troubleshooting below.
RaspAP hotspot log
Configuration file: /etc/hostapd/hostapd.conf
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
Using interface wlan0 with hwaddr 0c:8c:24:b6:f2:a6 and ssid "str1ker"
wlan0: interface state COUNTRY_UPDATE->ENABLED
wlan0: AP-ENABLED
wlan0: STA f0:18:98:0c:6d:45 IEEE 802.11: authenticated
wlan0: STA f0:18:98:0c:6d:45 IEEE 802.11: associated (aid 1)
wlan0: AP-STA-CONNECTED f0:18:98:0c:6d:45
wlan0: STA f0:18:98:0c:6d:45 RADIUS: starting accounting session 0C45B706D0EF1125
wlan0: STA f0:18:98:0c:6d:45 WPA: pairwise key handshake completed (RSN)
DNSMasq log
Oct 1 22:15:24 dnsmasq[1462]: started, version 2.80 cachesize 150
Oct 1 22:15:24 dnsmasq[1462]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify dumpfile
Oct 1 22:15:24 dnsmasq-dhcp[1462]: DHCP, IP range 10.3.141.50 -- 10.3.141.255, lease time 12h
Oct 1 22:15:24 dnsmasq[1462]: no servers found in /run/dnsmasq/resolv.conf, will retry
Oct 1 22:15:24 dnsmasq[1462]: read /etc/hosts - 5 addresses
System log
pi@raspberrypi:~ $ cat /var/log/messages | tail
Oct 1 22:17:17 raspberrypi kernel: [ 20.146878] rtl8192cu: Tx queue select: 0x05
Oct 1 22:17:19 raspberrypi kernel: [ 21.988367] wlan1: authenticate with cc:03:fa:de:05:22
Oct 1 22:17:19 raspberrypi kernel: [ 22.009269] wlan1: send auth to cc:03:fa:de:05:22 (try 1/3)
Oct 1 22:17:19 raspberrypi kernel: [ 22.107152] wlan1: authenticated
Oct 1 22:17:19 raspberrypi kernel: [ 22.114400] wlan1: associate with cc:03:fa:de:05:22 (try 1/3)
Oct 1 22:17:19 raspberrypi kernel: [ 22.174000] wlan1: RX AssocResp from cc:03:fa:de:05:22 (capab=0x411 status=0 aid=7)
Oct 1 22:17:19 raspberrypi kernel: [ 22.176697] wlan1: associated
Oct 1 22:17:19 raspberrypi kernel: [ 22.228962] IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
Oct 1 22:17:22 raspberrypi kernel: [ 24.541551] ICMPv6: process `dhcpcd' is using deprecated sysctl (syscall) net.ipv6.neigh.wlan1.retrans_time - use net.ipv6.neigh.wlan1.retrans_time_ms instead
Oct 4 10:08:03 raspberrypi rsyslogd: [origin software="rsyslogd" swVersion="8.1901.0" x-pid="380" x-info="https://www.rsyslog.com"] rsyslogd was HUPed
Kernel log
[ 6.134023] rtl8192cu: Loading firmware rtlwifi/rtl8192cufw_TMSC.bin
[ 6.134545] ieee80211 phy1: Selected rate control algorithm 'rtl_rc'
[ 6.142513] usbcore: registered new interface driver rtl8192cu
[ 7.958137] uart-pl011 fe201000.serial: no DMA platform data
[ 8.188917] random: crng init done
[ 8.188941] random: 7 urandom warning(s) missed due to ratelimiting
[ 8.395792] 8021q: 802.1Q VLAN Support v1.8
[ 8.734505] Adding 102396k swap on /var/swap. Priority:-2 extents:1 across:102396k SSFS
[ 8.840376] brcmfmac: brcmf_cfg80211_set_power_mgmt: power save enabled
[ 9.187847] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[ 9.317147] rtl8192cu: MAC auto ON okay!
[ 9.356984] rtl8192cu: Tx queue select: 0x05
[ 9.999716] bcmgenet fd580000.ethernet: configuring instance for external RGMII (RX delay)
[ 9.999992] bcmgenet fd580000.ethernet eth0: Link is Down
[ 10.879298] broken atomic modeset userspace detected, disabling atomic
[ 11.215947] wlan1: authenticate with cc:03:fa:de:05:22
[ 11.237745] wlan1: send auth to cc:03:fa:de:05:22 (try 1/3)
[ 11.325937] wlan1: authenticated
[ 11.334411] wlan1: associate with cc:03:fa:de:05:22 (try 1/3)
[ 11.402524] wlan1: RX AssocResp from cc:03:fa:de:05:22 (capab=0x411 status=0 aid=7)
[ 11.504807] wlan1: associated
[ 11.575156] cryptd: max_cpu_qlen set to 1000
[ 11.594080] IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
[ 13.249656] ieee80211 phy0: brcmf_vif_set_mgmt_ie: vndr ie set error : -52
Raspapd status
sudo systemctl status raspapd.service
Raspapd service is loaded but not running, last ran at installation time
-- Logs begin at Fri 2021-10-01 21:40:48 HDT, end at Fri 2021-10-01 21:41:55 HDT. --
Oct 01 21:40:59 raspberrypi systemd[1]: Starting RaspAP Service Daemon...
Oct 01 21:40:59 raspberrypi bash[816]: Stopping network services...
Oct 01 21:41:00 raspberrypi bash[816]: Changing RaspAP Daemon --interface to uap0
Oct 01 21:41:00 raspberrypi bash[816]: Disabling systemd-networkd
Oct 01 21:41:01 raspberrypi bash[816]: Starting network services...
Oct 01 21:41:08 raspberrypi bash[816]: RaspAP service start DONE
Oct 01 21:41:08 raspberrypi systemd[1]: raspapd.service: Succeeded.
Oct 01 21:41:08 raspberrypi systemd[1]: Started RaspAP Service Daemon.
Hostapd status
root@raspberrypi:~ # systemctl status hostapd
● hostapd.service - Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator
Loaded: loaded (/lib/systemd/system/hostapd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-10-01 21:48:07 HDT; 2min 7s ago
Process: 2283 ExecStart=/usr/sbin/hostapd -B -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF} (code=exited, status=0/SUCCESS)
Main PID: 2284 (hostapd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/hostapd.service
└─2284 /usr/sbin/hostapd -B -P /run/hostapd.pid -B -f /tmp/hostapd.log /etc/hostapd/hostapd.conf
Oct 01 21:48:06 raspberrypi systemd[1]: Starting Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator...
Oct 01 21:48:07 raspberrypi systemd[1]: Started Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator.
Oct 01 21:48:15 raspberrypi hostapd[2284]: wlan0: STA f0:18:98:0c:6d:45 IEEE 802.11: authenticated
Oct 01 21:48:15 raspberrypi hostapd[2284]: wlan0: STA f0:18:98:0c:6d:45 IEEE 802.11: associated (aid 1)
Oct 01 21:48:15 raspberrypi hostapd[2284]: wlan0: STA f0:18:98:0c:6d:45 RADIUS: starting accounting session 0C45B706D0EF1125
Oct 01 21:48:15 raspberrypi hostapd[2284]: wlan0: STA f0:18:98:0c:6d:45 WPA: pairwise key handshake completed (RSN)
DNSMasq status
root@raspberrypi:~ # systemctl status dnsmasq
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-10-01 21:48:13 HDT; 2min 59s ago
Process: 2343 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
Process: 2344 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
Process: 2353 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
Main PID: 2352 (dnsmasq)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/dnsmasq.service
└─2352 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dp
Oct 01 21:48:13 raspberrypi systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Oct 01 21:48:13 raspberrypi dnsmasq[2343]: dnsmasq: syntax check OK.
Oct 01 21:48:13 raspberrypi dnsmasq[2353]: Too few arguments.
Oct 01 21:48:13 raspberrypi systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.