RaspberryPi 3 as Wifi Access Point

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
MatejKovacic
 
Posts: 7
Joined: Thu Aug 18, 2016 5:04 pm

RaspberryPi 3 as Wifi Access Point

Post by MatejKovacic »

Hi,

I followed your great tutorial about how to create a Wifi Access Point from your RaspberryPi 3, but run to some errors.

First, I did some minor modifications, but these could not be a problem.

I decided to use IP range from 172.16.0.10 to 172.16.0.50. So in /etc/dhcp/dhcpd.conf I put this:

Code: Select all

subnet 172.16.0.0 netmask 255.255.255.0 {
        range 172.16.0.10 172.16.0.50;
        option broadcast-address 172.16.0.255;
        option routers 172.16.0.1;
        default-lease-time 600;
        max-lease-time 7200;
        option domain-name "local";
        option domain-name-servers 8.8.8.8, 8.8.4.4;
}
Of course I configured wlan0 to have correct IP address, namely:

Code: Select all

sudo ifconfig wlan0 172.16.0.1
My /etc/hostapd/hostapd.conf is the same, I changed only my SSID (which is set to BlueSensor), country code (SI) and since I want to use the Raspberry Pi 3's internal WiFi adapter I completely removed this line;

Code: Select all

driver=rtl871xdrv
Then I run:

Code: Select all

sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
...and get this:

Code: Select all

Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:cc:f0:87 and ssid "BlueSensor"
wlan0: interface state COUNTRY_UPDATE->ENABLED
wlan0: AP-ENABLED
I am running Raspbian Jessie (fully updated), and I have also run sudo rpi-update.

OK, now to the problem...

I can see SSID and I can connect to my new shiny AP. However, when I connected to it with my Android phone, there is no internet connection and I cannot see website running on RaspberryPi - I am running tornado web server, which is listening to 172.16.0.1:8881.

Next try was connection to my AP with Ubuntu laptop. Connection was successful, I can get access to the internet and I can successfully connect to 172.16.0.1:8881.

Then I reboot the RaspberryPi device and tried to connect again. Now, connection from the laptop was possible, but there was no internet connection and I couldnt see web service on 172.16.0.1:8881.

Is it possible there is a problem with some wifi kernel drivers? Is this somehow connected to the error message above:

Code: Select all

Failed to create interface mon.wlan0: -95 (Operation not supported)
...
wlan0: Could not connect to kernel driver
Any help will be really appreciated.

Regards, M.

User avatar
MatejKovacic
 
Posts: 7
Joined: Thu Aug 18, 2016 5:04 pm

Re: RaspberryPi 3 as Wifi Access Point

Post by MatejKovacic »

OK, I went a little bit more into debugging and found this...

I set the RPi AP to channel 8.

I am able to connect on the RPi AP with computer, I can access local website (http://172.16.0.1:8881 - locaten on RPi AP) and I can access internet. This is from computer.

Anyway, I tried to connect to AP with several mobile phones. Two of them were Samsung Galaxy with stock Android and they CAN connect, CAN access local website (on RPi AP), but they DO NOT have internet access. However, when I connect with my personal phone (Nexus 5 with CyanogenMod), I DO NOT have internet access and CAN NOT access local website on RPi AP.

Then I did this:

First, I changed hostapd.conf a little bit. I enabled WPA1 and WPA2 and also TKIP:

Code: Select all

wpa=3
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP TKIP
rsn_pairwise=CCMP
Here is the log of hostapd on RPi while connecting to it with my mobile phone:

Code: Select all

sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf

Code: Select all

Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:cc:f0:87 and ssid "BlueSensor"
wlan0: interface state COUNTRY_UPDATE->ENABLED
wlan0: AP-ENABLED
wlan0: STA 34:4d:f7:47:b1:4f IEEE 802.11: associated
wlan0: AP-STA-CONNECTED 34:4d:f7:47:b1:4f
wlan0: STA 34:4d:f7:47:b1:4f RADIUS: starting accounting session 59311E17-00000000
wlan0: STA 34:4d:f7:47:b1:4f WPA: pairwise key handshake completed (WPA)
wlan0: STA 34:4d:f7:47:b1:4f WPA: group key handshake completed (WPA)
Mobile phone IS connected and has IP address assigned (172.16.0.11) I can also ping mobile phone from RPi AP.

However, as I said, I DO NOT have internet access from mobile phone and CAN NOT access local website on RPi AP from mobile phone.

So I run adb shell connection to mobile phone, and I can see the network:

Code: Select all

ifconfig

Code: Select all

...
wlan0     Link encap:UNSPEC
          inet addr:172.16.0.11  Bcast:172.16.0.255  Mask:255.255.255.0
          inet6 addr: fe80::364d:f7ff:fe47:b14f/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19501 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18698 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:10918688 TX bytes:2990567
However, I CAN NOT ping RPi AP from mobile phone:

Code: Select all

shell@hammerhead:/ $ ping 172.16.0.1


(no reply). Anyway, since there is no internet connection, mobile phone activates rmnet0, so I have internet connection via 4G.

Ah, and route print via ADB:

Code: Select all

shell@hammerhead:/ $ route

Code: Select all

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
109.239.187.4   172.19.116.208  255.255.255.255 UGH   0      0        0 rmnet0
109.239.187.20  172.19.116.208  255.255.255.255 UGH   0      0        0 rmnet0
172.16.0.0      *               255.255.255.0   U     0      0        0 wlan0
172.19.116.192  *               255.255.255.224 U     0      0        0 rmnet0
Now I am really out of ideas...

User avatar
MatejKovacic
 
Posts: 7
Joined: Thu Aug 18, 2016 5:04 pm

Re: RaspberryPi 3 as Wifi Access Point

Post by MatejKovacic »

OK, I also tried to run tcpdump on RPi AP:

Code: Select all

sudo tcpdump -i wlan0
After recconnection I get this:

Code: Select all

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wlan0, link-type EN10MB (Ethernet), capture size 262144 bytes
10:42:43.898225 34:4d:f7:47:b1:4f (oui Unknown) > Broadcast Null Unnumbered, xid, Flags [Response], length 6: 01 00
10:42:43.901171 EAPOL key (3) v2, len 95
10:42:43.972974 EAPOL key (3) v1, len 119
10:42:43.974444 EAPOL key (3) v2, len 123
10:42:43.979761 EAPOL key (3) v1, len 95
10:42:43.983507 EAPOL key (3) v2, len 135
10:42:43.989508 EAPOL key (3) v1, len 95
10:42:44.097824 IP6 :: > ff02::1:ff47:b14f: ICMP6, neighbor solicitation, who has fe80::364d:f7ff:fe47:b14f, length 24
10:42:44.104857 IP6 :: > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28
10:42:44.218310 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 34:4d:f7:47:b1:4f (oui Unknown), length 314
10:42:44.219064 IP 172.16.0.1.bootps > 172.16.0.11.bootpc: BOOTP/DHCP, Reply, length 300
10:42:44.225425 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 34:4d:f7:47:b1:4f (oui Unknown), length 326
10:42:44.226248 IP 172.16.0.1.bootps > 172.16.0.11.bootpc: BOOTP/DHCP, Reply, length 300
10:42:44.396118 ARP, Request who-has 172.16.0.1 tell 172.16.0.11, length 28
10:42:54.408909 IP 172.16.0.11.52179 > google-public-dns-a.google.com.domain: 54785+ AAAA? connectivitycheck.gstatic.com. (47)
10:42:59.411431 IP 172.16.0.11.52449 > google-public-dns-b.google.com.domain: 54785+ AAAA? connectivitycheck.gstatic.com. (47)
10:43:09.417460 ARP, Request who-has 172.16.0.1 tell 172.16.0.11, length 28
10:43:19.427214 IP 172.16.0.11.43419 > google-public-dns-b.google.com.domain: 62498+ A? connectivitycheck.gstatic.com. (47)
10:43:24.430657 IP 172.16.0.11.37642 > google-public-dns-a.google.com.domain: 63837+ AAAA? connectivitycheck.gstatic.com.local. (53)
10:43:29.437642 IP 172.16.0.11.1231 > google-public-dns-b.google.com.domain: 63837+ AAAA? connectivitycheck.gstatic.com.local. (53)
10:43:34.442038 ARP, Request who-has 172.16.0.1 tell 172.16.0.11, length 28
10:43:34.442330 ARP, Reply 172.16.0.1 is-at b8:27:eb:cc:f0:87 (oui Unknown), length 28
10:43:34.443168 IP 172.16.0.11.37642 > google-public-dns-a.google.com.domain: 63837+ AAAA? connectivitycheck.gstatic.com.local. (53)

User avatar
MatejKovacic
 
Posts: 7
Joined: Thu Aug 18, 2016 5:04 pm

Re: RaspberryPi 3 as Wifi Access Point

Post by MatejKovacic »

Okaaay... I tried to connect to RPi AP with Windows 10 laptop... It DOES connect, it CAN access website at RPi AP, but there is no internet connection. OK, at least I am able to connecct to RPi AP website (172.16.0.1:8881).

Anyway, I am thinking there could be some problem with IPv6? Something connected to DNS (AAAA requests in tcpdump) or routing? Now this is something I need some help.

User avatar
MatejKovacic
 
Posts: 7
Joined: Thu Aug 18, 2016 5:04 pm

Re: RaspberryPi 3 as Wifi Access Point

Post by MatejKovacic »

OK, I managed to figure out the problem.

Bastards at our organisation are blocking Google DNS servers (8.8.8.8 and 8.8.4.4).

When I entered our local DNS server in dhcpd.conf, everything magically started to work, even internet connection.

The most weird thing for me is, that DNS is somehow connected with routing on Android. If DNS is not working, routing to "local" IP addresses is also not working. Or so it seems.

Anyway, project accomplished. Well, almost. :-)

Hope this helps to anyone else with similar problems.

Locked
Please be positive and constructive with your questions and comments.

Return to “Wireless: WiFi and Bluetooth”