I'm trying to create a simple WPA2 WiFi access point so that I can use WiFi more reliably when I'm far away from the router.
I'm following this guide except I'm using a custom version of hostapd that has the driver for my USB WiFi dongle.
I modify the hostapd.conf configuration slightly from the guide to create an open hotspot:
interface=wlan0
ssid=WiFi
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
driver=rtl871xdrv
ieee80211n=1
hw_mode=g
device_name=RTL8192CU
manufacturer=Realtek
When I do this, everything works like a charm and I can browse the Internet when connected to the AP from my phone.
But, of course, an open AP is not desirable and I wish to create a WPA2 AP so I modify the configuration file:
interface=wlan0
ssid=WiFi
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Raspberry5
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
driver=rtl871xdrv
ieee80211n=1
hw_mode=g
device_name=RTL8192CU
manufacturer=Realtek
This does not work like a charm! Despite entering the correct password, "Raspberry5" when connecting to the AP, my phone (running Android Marshmallow) hangs on "Connecting…" for a while before returning to "Saved…" and then returning to "Connecting…" This occurs endlessly, with "Authentication problem" occasionally flashing up. Other devices also fail to connect.
How can I resolve this problem so that I am able to connect to the AP successfully?
Here's the output of hostapd -d /etc/hostapd/hostapd.conf:
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
drv->ifindex=3
l2_sock_recv==l2_sock_xmit=0x0xb69648
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
Completing interface initialization
Mode: IEEE 802.11g Channel: 6 Frequency: 2437 MHz
RATE[0] rate=10 flags=0x1
RATE[1] rate=20 flags=0x1
RATE[2] rate=55 flags=0x1
RATE[3] rate=110 flags=0x1
RATE[4] rate=60 flags=0x0
RATE[5] rate=90 flags=0x0
RATE[6] rate=120 flags=0x0
RATE[7] rate=180 flags=0x0
RATE[8] rate=240 flags=0x0
RATE[9] rate=360 flags=0x0
RATE[10] rate=480 flags=0x0
RATE[11] rate=540 flags=0x0
Flushing old station entries
Deauthenticate all stations
+rtl871x_sta_deauth_ops, ff:ff:ff:ff:ff:ff is deauth, reason=2
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
Using interface wlan0 with hwaddr 80:1f:02:d0:f5:94 and ssid 'WiFi'
Deriving WPA PSK based on passphrase
SSID - hexdump_ascii(len=4):
57 69 46 69 WiFi
PSK (ASCII passphrase) - hexdump_ascii(len=10): [REMOVED]
PSK (from passphrase) - hexdump(len=32): [REMOVED]
rtl871x_set_wps_assoc_resp_ie
rtl871x_set_wps_beacon_ie
rtl871x_set_wps_probe_resp_ie
urandom: Got 20/20 bytes from /dev/urandom
GMK - hexdump(len=32): [REMOVED]
Key Counter - hexdump(len=32): [REMOVED]
WPA: group state machine entering state GTK_INIT (VLAN-ID 0)
GTK - hexdump(len=16): [REMOVED]
WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)
rtl871x_set_key_ops
rtl871x_set_beacon_ops
rtl871x_set_hidden_ssid ignore_broadcast_ssid:0, WiFi,4
rtl871x_set_acl
wlan0: Setup of interface done.
Here's /etc/network/interfaces:
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet static
address 10.0.1.1
netmask 255.255.255.0
up iptables-restore < /etc/iptables.ipv4.nat
And here's /etc/dhcp/dhcpd.conf without comments:
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
subnet 10.0.1.0 netmask 255.255.255.0 {
range 10.0.1.2 10.0.1.254;
option broadcast-address 10.0.1.255;
option routers 10.0.1.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 10.0.0.1, 8.8.8.8;
}
I've modified both /etc/network/interfaces and /etc/dhcp/dhcp.conf from the guide to use the IP address range that I wish to use.
Thanks in advance for any help and of course, I'll be glad to provide any more logs/files that are useful.
Best Answer
OK, I've got it working.
I linked to this post on the Raspberry Pi Forums and a user, epoch1970, told me that the custom version of hostapd is no longer required for devices with the RTL8188CUS chipset, which mine is. In fact, you cannot use it - you encounter the issue I experienced!
He linked to this thread on the forum, which explains things.
I clean-installed Raspbian and installed hostapd from the repo, specified driver=nl80211 in my hostapd config and everything worked brilliantly.