On a new install of DietPi, I’m having problems getting HotSpot mode to work. In reviewing various troubleshooting articles, I’ve gotten to the point where I don’t have anymore error messages to chase down. From the OS side it looks likes like everything is working.
None of my devices see the hotspot as an available network to connect to. I’ve tried to connect to it with the default SSID/password and the devices report network not found. I can connect to my home wlan with the WiFi adapter, an RTL8723bs so it seems to be working.
Yes, kind of. The Pine A64 was sold with an optional WiFi card that plugged into the motherboard. Not USB. The WiFi card does work as a client on wlan.
eA64 systemd\[1\]: Starting hostapd.service - Access point and authentication server for Wi-Fi and Ethernet...
Oct 02 14:59:17 PineA64 (hostapd)\[595\]: **hostapd.service: Referenced but unset environment variable evaluates to an empty string: DAEMON_OPTS**
Oct 02 14:59:18 PineA64 hostapd\[595\]: wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
Oct 02 14:59:18 PineA64 hostapd\[595\]: wlan0: interface state COUNTRY_UPDATE->ENABLED
Oct 02 14:59:18 PineA64 hostapd\[595\]: wlan0: AP-ENABLED
Oct 02 14:59:18 PineA64 systemd\[1\]: Started hostapd.service - Access point and authentication server for Wi-Fi and Ethernet.
Oct 02 15:22:44 PineA64 systemd\[1\]: Stopping hostapd.service - Access point and authentication server for Wi-Fi and Ethernet...
Oct 02 15:22:44 PineA64 systemd\[1\]: hostapd.service: Deactivated successfully.
Oct 02 15:22:44 PineA64 systemd\[1\]: Stopped hostapd.service - Access point and authentication server for Wi-Fi and Ethernet.
Oct 02 15:22:45 PineA64 systemd\[1\]: Starting hostapd.service - Access point and authentication server for Wi-Fi and Ethernet...
Oct 02 15:22:45 PineA64 (hostapd)\[1998\]: **hostapd.service: Referenced but unset environment variable evaluates to an empty string: DAEMON_OPTS**
Oct 02 15:22:45 PineA64 hostapd\[1998\]: wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
Oct 02 15:22:45 PineA64 hostapd\[1998\]: wlan0: interface state COUNTRY_UPDATE->ENABLED
Oct 02 15:22:45 PineA64 hostapd\[1998\]: wlan0: AP-ENABLED
Oct 02 15:22:45 PineA64 systemd\[1\]: Started hostapd.service - Access point and authentication server for Wi-Fi and Ethernet.
So you tried SSID DietPi-HotSpot with key dietpihotspot?
At least worth to try with the USB WiFi adapter. There are indeed some which simple do not support AP mode.
To verify another thing:
lsmod | grep 8723bs
It seems we explicitly load a wrong kernel module 8723bs vs r8723bs. The correct one should load automatically, but we’d still want to fix this in our script.
Ok, I think I found the problem. The “iw dev wlan0 info” command output had my OG, non-hotspot SSID name in it. This was the name of my home WiFi network, that I coded into the /boot/dietpi-wifi.txt file when I first installed DietPi, and before I installed and configured hosted (60).
I commented out the configuration in /etc/wpa_supplicant/wpa_supplicant.conf and rebooted
It took several tries to convince my Mac to connect to the hotspot network, but it finally did and everything seems to be working well.
Ah wait a second. I see this is our code in dietpi-network:
if [[ $CURRENT_IFACE_TYPE == 'wifi' ]]
then
content+=$'\n''wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf'
# Disable power savings mode if supported
if iw dev "$iface" set power_save on 2> /dev/null && iw dev "$iface" set power_save off 2> /dev/null
then
content+=$'\n'"pre-up iw dev $iface set power_save off || true"
content+=$'\n'"post-down iw dev $iface set power_save on || true"
fi
# WiFi Hotspot
if (( $CURRENT_IFACE_HOTSPOT ))
then
content+=$'\n''up iptables-restore < /etc/iptables.ipv4.nat'
content+=$'\n''up ip6tables-restore < /etc/iptables.ipv6.nat'
[[ -f '/etc/hostapd/hostapd.conf' ]] && G_CONFIG_INJECT 'interface=' "interface=$iface" /etc/hostapd/hostapd.conf
[[ -f '/etc/default/isc-dhcp-server' ]] && G_CONFIG_INJECT 'INTERFACESv4=' "INTERFACESv4=\"$iface\"" /etc/default/isc-dhcp-server
fi
fi
So it unnecessarily starts wpa_supplicant via wpa-conf config key, even when the interface is configured as hotspot. When it succeeds to connect to another network, I guess it disables AP mode, hence breaks the hotspot.
Looking through things, I recognized that it is also possible to add hostapd /etc/hostapd/hostapd.conf to the /etc/network/interfaces.d config, to let ifupdown start hostapd when the interface is configured, which renders the hostapd.service obsolete. So this works very similar to wpa-conf vs wpa_supplicant.service.
But the DHCP server at least is still needed as dedicated service, and there might be also some benefit to be able to restart hostapd separately. … and /etc/hostapd/hostapd.conf still needs to contain the interface setting, since this cannot be set via hostapd CLI. So it is not exactly well made to be invoked by ifupdown for a particular interface.