#StackBounty: #android #access-point #systemd-networkd #wpa-supplicant Android won't connect to RasPi access point

Bounty: 50

I have managed to turn my Raspberry Pi into an access point following these instructions:

Access point as WiFi router/repeater with additional WiFi-dongle

However, everything connects to the access point except my android devices (A Samsung Galaxy Note 8 and a Samsung Galaxy S5).

A similar problem is presented in this question:

Android cannot connect to Pi's wlan

However, the answer given there does not apply to me since I have the file /etc/systemd/network/08-wlan0.network exactly as in the first link. (hence with DHCP server activated):

[Match]
Name=wlan0
[Network]
Address=192.168.4.1/24
IPForward=yes
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1

How can I fix it?

Further information:

Problem Description

Both my devices can see the network.
The Galaxy Note 8 keeps trying to connect, when I insert the password it says “Connecting…” under the SSID for approximately 3 seconds stops showing the message for 2 seconds and then keeps trying to connect.
Almost the same with the Galaxy S5 with the difference that it also writes “Obtaining IP address” before stopping and then keeps retrying.

Check on DHCP (as apparently is a known issue, see second link)

Journalctl does not seem to show DHCP requests, hence I have extended the log as described here:

https://superuser.com/questions/1187633/how-to-debug-systemd-networkd

Launching journalctl -b -u systemd-networkd, I have tried to reconnect several times with my android devices From 12:16 on, however I see only two DHCP server requests.

Jan 11 12:14:28 raspberrypi systemd-networkd[855]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_33 interface=org.freedesktop.DBus.Properties member=PropertiesCh
Jan 11 12:16:04 raspberrypi systemd-networkd[855]: DHCP SERVER: REQUEST (rebinding/renewing) (0x4f98fb1a)
Jan 11 12:16:04 raspberrypi systemd-networkd[855]: DHCP SERVER: ACK (0x4f98fb1a)
Jan 11 12:17:39 raspberrypi systemd-networkd[855]: DHCP SERVER: REQUEST (rebinding/renewing) (0x26d7c444)
Jan 11 12:17:39 raspberrypi systemd-networkd[855]: DHCP SERVER: ACK (0x26d7c444)

Check on wpa_supplicant@wlan0.service

I get

root@raspberrypi:~ # journalctl -b -u wpa_supplicant@wlan0.service 
-- Logs begin at Sat 2020-01-11 10:03:13 CST, end at Sat 2020-01-11 12:28:44 CST. --
Jan 11 10:03:16 raspberrypi systemd[1]: Started WPA supplicant daemon (interface-specific version).
Jan 11 10:03:17 raspberrypi wpa_supplicant[352]: Successfully initialized wpa_supplicant
Jan 11 10:03:17 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=US
Jan 11 10:03:21 raspberrypi wpa_supplicant[352]: wlan0: Could not connect to kernel driver
Jan 11 10:03:21 raspberrypi wpa_supplicant[352]: Using interface wlan0 with hwaddr **DeviceMac** and ssid "**Device_SSID**"
Jan 11 10:03:21 raspberrypi wpa_supplicant[352]: wlan0: interface state UNINITIALIZED->ENABLED
Jan 11 10:03:21 raspberrypi wpa_supplicant[352]: wlan0: AP-ENABLED
Jan 11 10:03:21 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-CONNECTED - Connection to **DeviceMac** completed [id=0 id_str=]
Jan 11 10:04:47 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 10:04:47 raspberrypi wpa_supplicant[352]: wlan0: AP-STA-CONNECTED **MAC_OF_PC1**
Jan 11 10:05:12 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 10:05:12 raspberrypi wpa_supplicant[352]: wlan0: AP-STA-CONNECTED **MAC_OF_PC2**
Jan 11 10:05:19 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
Jan 11 10:05:19 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=US
Jan 11 10:06:06 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 10:06:14 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 10:06:21 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 11:04:32 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
Jan 11 11:04:33 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=US
Jan 11 11:13:47 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 11:13:55 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:16:25 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:16:32 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:16:32 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:16:48 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:16:55 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:17:03 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:17:15 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:18:17 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:18:25 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:18:33 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:18:41 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:18:49 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:18:57 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:19:05 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:19:13 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:20:15 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:20:23 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:20:31 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:28:22 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:28:29 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:28:37 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 11 12:28:44 raspberrypi wpa_supplicant[352]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0

At least I see the connection attempts at their right times as CTRL-EVENT-SUBNET-STATUS-UPDATE status=0.

I have also tried to submit a wrong password, in this case I get:

Jan 11 12:37:12 raspberrypi wpa_supplicant[352]: wlan0: AP-STA-POSSIBLE-PSK-MISMATCH **PhoneAddress**
Jan 11 12:37:13 raspberrypi wpa_supplicant[352]: wlan0: AP-STA-POSSIBLE-PSK-MISMATCH **PhoneAddress**
Jan 11 12:37:14 raspberrypi wpa_supplicant[352]: wlan0: AP-STA-POSSIBLE-PSK-MISMATCH **PhoneAddress**
Jan 11 12:37:15 raspberrypi wpa_supplicant[352]: wlan0: AP-STA-POSSIBLE-PSK-MISMATCH **PhoneAddress**

Ipv6?

I found out that in order to download updates faster it was convenient to switch off RasPi Ipv6. Could this interfere? I had this doubt since when I connected to the network from a windows machine I found out in the WiFi properties that there is a Link-local IPv6 address. Since it is often claimed that Link-local is what is not supported in android, it might be that the Ipv6 settings are necessary for android to connect to a wifi network. But how to switch on IPv6 and set DHCP inside systemd-networkd?

However from this:

https://stackoverflow.com/questions/37978595/what-triggers-assigning-ipv6-link-local-address-in-android

I deduce that android devices are capable of getting a link-local Ipv6 address.

Another similar question

Access Point not working for Android phones

But the answers do not make sense to me.

I have tried to change /etc/systemd/network/08-wlan0.network to

[Match]
Name=wlan0
[Network]
Address=10.10.11.1/24
IPForward=yes
DHCPServer=yes
[DHCPServer]
DNS=84.200.69.80 1.1.1.1

then from ifconfig on my laptop I get:

wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.10.11.72  netmask 255.255.255.0  broadcast 10.10.11.255
        inet6 fe80::aeee:ee4:1a78:6517  prefixlen 64  scopeid 0x20<link>
        ether **MACADDRESS**  txqueuelen 1000  (Ethernet)
        RX packets 15397  bytes 8998330 (8.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 9034  bytes 2177688 (2.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

And still can not connect from mobile.
I also changed it to Address=192.168.0.0/24 and I couldn’t connect this time also from the pcs, however from journalctl -b -u wpa_supplicant@wlan0.service I got a different error from the pcs and the from the android devices (and the error given to the android devices is the same old one).

Jan 12 09:33:43 raspberrypi wpa_supplicant[359]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 12 09:33:47 raspberrypi wpa_supplicant[359]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 12 09:33:51 raspberrypi wpa_supplicant[359]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 12 09:34:07 raspberrypi wpa_supplicant[359]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 12 09:34:11 raspberrypi wpa_supplicant[359]: wlan0: AP-STA-DISCONNECTED f8:54:b8:85:45:01
Jan 12 09:34:16 raspberrypi wpa_supplicant[359]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 12 09:34:25 raspberrypi wpa_supplicant[359]: wlan0: AP-STA-DISCONNECTED 60:14:b3:6d:a0:af
Jan 12 09:34:26 raspberrypi wpa_supplicant[359]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Jan 12 09:34:26 raspberrypi wpa_supplicant[359]: wlan0: AP-STA-CONNECTED 60:14:b3:6d:a0:af
Jan 12 09:35:11 raspberrypi wpa_supplicant[359]: wlan0: AP-STA-DISCONNECTED 60:14:b3:6d:a0:af

Debugging from Android

Thanks to adb shell I was able to launch dumpsys wifi on my galaxy S5, and I got

Working connection

01-12 14:16:22.185 - Event [IFNAME=wlan0 CTRL-EVENT-STATE-CHANGE id=33 state=6 BSSID=00:00:00:00:00:00 SSID=**PhoneNetwork**]
01-12 14:16:22.185 - Event [IFNAME=wlan0 Associated with **PhoneHotspotMAC**]
01-12 14:16:22.211 - Event [IFNAME=wlan0 CTRL-EVENT-STATE-CHANGE id=33 state=7 BSSID=**PhoneHotspotMAC** SSID=**PhoneNetwork**]
01-12 14:16:22.211 - Event [IFNAME=wlan0 WPA: RX message 1 of 4-Way Handshake from 6E.3F.F0 (ver=2)]
01-12 14:16:22.212 - Event [IFNAME=wlan0 WPA: Sending EAPOL-Key 2/4]
01-12 14:16:22.231 - Event [IFNAME=wlan0 WPA: RX message 3 of 4-Way Handshake from 6E.3F.F0 (ver=2)]
01-12 14:16:22.233 - Event [IFNAME=wlan0 WPA: Sending EAPOL-Key 4/4]
01-12 14:16:22.234 - Event [IFNAME=wlan0 CTRL-EVENT-STATE-CHANGE id=33 state=8 BSSID=**PhoneHotspotMAC** SSID=**PhoneNetwork**]
01-12 14:16:22.235 - Event [IFNAME=wlan0 WPA: Key negotiation completed with **PhoneHotspotMAC** [PTK=CCMP GTK=CCMP]]
01-12 14:16:22.235 - Event [IFNAME=wlan0 CTRL-EVENT-CONNECTED - Connection to **PhoneHotspotMAC** completed [id=33 id_str=]]
01-12 14:16:22.236 - Event [IFNAME=wlan0 CTRL-EVENT-STATE-CHANGE id=33 state=9 BSSID=**PhoneHotspotMAC** SSID=**PhoneNetwork**]
01-12 14:16:22.242 - wlan0: 4486:IFNAME=wlan0 GET FREQUENCY -> 2457
01-12 14:16:22.242 - wlan0: 4487:IFNAME=wlan0 SET_NETWORK 33 verified_password 1 -> true
01-12 14:16:22.251 - wlan0: 4488:IFNAME=wlan0 SAVE_CONFIG -> true
01-12 14:16:22.255 - wlan0: 4489:IFNAME=wlan0 SET pno 0 -> true
01-12 14:16:22.277 - wlan0: 4490:IFNAME=wlan0 PKTCNT_POLL -> TXGOOD=26571
TXBAD=508
RXGOOD=753
01-12 14:16:22.360 - wlan0: 4491:IFNAME=wlan0 DRIVER BTCOEXMODE 1 -> true
01-12 14:16:22.365 - wlan0: 4492:IFNAME=wlan0 DRIVER SETSUSPENDMODE 0 -> true
01-12 14:16:22.366 - wlan0: 4493:IFNAME=wlan0 SET ps 0 -> true
01-12 14:16:22.383 - wlan0: 4494:IFNAME=wlan0 LIST_NETWORKS -> network id / ssid / bssid / flags

Not working connection

01-12 14:16:59.083 - Event [IFNAME=wlan0 CTRL-EVENT-STATE-CHANGE id=32 state=6 BSSID=00:00:00:00:00:00 SSID=**RasPiNetwork**]
01-12 14:16:59.084 - Event [IFNAME=wlan0 Associated with **RasPiMAC**]
01-12 14:16:59.084 - Event [IFNAME=wlan0 CTRL-EVENT-STATE-CHANGE id=32 state=7 BSSID=**RasPiMAC** SSID=**RasPiNetwork**]
01-12 14:16:59.085 - Event [IFNAME=wlan0 WPA: RX message 1 of 4-Way Handshake from DC.FF.96 (ver=2)]
01-12 14:16:59.086 - Event [IFNAME=wlan0 WPA: Sending EAPOL-Key 2/4]
01-12 14:16:59.093 - Event [IFNAME=wlan0 WPA: RX message 3 of 4-Way Handshake from DC.FF.96 (ver=2)]
01-12 14:16:59.095 - Event [IFNAME=wlan0 WPA: Sending EAPOL-Key 4/4]
01-12 14:16:59.095 - Event [IFNAME=wlan0 CTRL-EVENT-STATE-CHANGE id=32 state=8 BSSID=**RasPiMAC** SSID=**RasPiNetwork**]
01-12 14:17:03.112 - Event [IFNAME=wlan0 CTRL-EVENT-BIGDATA-DISCONNECT 2 36 1 2 dc:a6:32 2462 20 -40 72 2 0 x x 0 -92 0 0]
01-12 14:17:03.112 - Event [IFNAME=wlan0 CTRL-EVENT-DISCONNECTED bssid=**RasPiMAC** reason=2]
01-12 14:17:03.113 - Event [IFNAME=wlan0 CTRL-EVENT-STATE-CHANGE id=32 state=0 BSSID=**RasPiMAC** SSID=**RasPiNetwork**]
01-12 14:17:03.212 - Event [IFNAME=wlan0 CTRL-EVENT-STATE-CHANGE id=-1 state=3 BSSID=00:00:00:00:00:00 SSID=]
01-12 14:17:03.219 - Event [IFNAME=wlan0 CTRL-EVENT-SCAN-STARTED ]
01-12 14:17:05.402 - wlan0: 4581:IFNAME=wlan0 SET pno 0 -> true
01-12 14:17:05.404 - wlan0: 4582:IFNAME=wlan0 SCAN -> false
01-12 14:17:06.984 - wlan0: 4583:IFNAME=wlan0 SET pno 0 -> true
01-12 14:17:06.985 - wlan0: 4584:IFNAME=wlan0 SCAN -> false
01-12 14:17:07.024 - Event [IFNAME=wlan0 CTRL-EVENT-SCAN-RESULTS ]
01-12 14:17:07.024 - Event [IFNAME=wlan0 WPS-AP-AVAILABLE ]
01-12 14:17:07.043 - Event [IFNAME=wlan0 Trying to associate with **RasPiMAC** (SSID='**RasPiNetwork**' freq=2462 MHz level=-38) ]
01-12 14:17:07.046 - Event [IFNAME=wlan0 CTRL-EVENT-STATE-CHANGE id=32 state=5 BSSID=00:00:00:00:00:00 SSID=**RasPiNetwork**]
01-12 14:17:07.077 - wlan0: 4585:IFNAME=wlan0 LIST_NETWORKS -> network id / ssid / bssid / flags

Apparently (reason = 2) (https://www.cisco.com/assets/sol/sb/WAP371_Emulators/WAP371_Emulator_v1-0-1-5/help/Apx_ReasonCodes2.html) stands for “Previous authentication no longer valid”.

Possible Path to a solution

From here

https://community.ui.com/questions/Android-devices-always-disconnecting-on-AP-AC-Pro/8512e697-1720-43b0-b0ee-591686b7f458?page=1

I got that “So somehow, having Multicast / Broadcast on my network kicks my Android devices”. I don’t even know how to chekc if my hotspot has those or can avoid those.

Here this multicast issue is vaguely addressed:

https://stackoverflow.com/questions/13221736/android-device-not-receiving-multicast-package

In partucular the comment “This page has a wealth of information about which IP to use as per your needs. ” reminds me of a similar comment in an answer at the link under the section “another similar question” however the link does not seem to help.

Launching systemd-resolve --status I get

Link 4 (wlan0)
      Current Scopes: none
DefaultRoute setting: no
       LLMNR setting: no
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: allow-downgrade
    DNSSEC supported: yes

However I still can not connect from my smartphones.

Final Attempt

I have tried to do the whole process again, burning the image on an SD card and so on. Without the net forwarding but only with the access point with systemd… I confirm that android devices can not connect to it. It is incredible that it looks like I am the only one worried about this problem!


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.