I wanted this capability for various reasons. It's not necessarily stable, because uap0 has to use the same channel as wlan0, and if you're traveling/mobile, wifi channels aren't necessarily predictable.
This is not a guide. This is just so I remember how to get back where I started, in case I wipe this thing. =)
Extremely helpful guides that got me here:
- http://imti.co/post/145442415333/raspberry-pi-3-wifi-station-ap
- https://serverfault.com/questions/124774/have-a-service-start-on-startup-with-ubuntu
- https://raspberrypi.stackexchange.com/questions/63841/rpi-zero-w-as-both-wifi-client-and-access-point
In my particular configuration, the Pi was set up with a hostname of altoid
. With the avahi
tweak, I am now
consistently able to access the Pi via altoid.local
from machines on the same network (or connected directly, via the AP).
Out of the box, I used the "NOOBS" that comes preloaded, got internet via wifi, and selected to install Raspbian Lite
.
After that, I installed dnsmasq
, and hostapd
. Not sure if anything else was required.
source-directory /etc/network/interfaces.d auto lo auto eth0 auto wlan0 auto uap0 iface lo inet loopback iface eth0 inet dhcp allow-hotplug wlan0 iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf iface uap0 inet static address 192.168.50.1 netmask 255.255.255.0 network 192.168.50.0 broadcast 192.168.50.255 gateway 192.168.50.1
# Lots of default stuff commented out. # Then this... interface=lo,uap0 no-dhcp-interface=lo,wlan0 bind-interfaces server=8.8.8.8 domain-needed bogus-priv dhcp-range=192.168.50.50,192.168.50.150,12h
# Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi # I don't think this part even works...? printf "Sleeping for 5 seconds befor hostapdstart" sleep 5 hostapdstart >1& exit 0
#!/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin iw dev wlan0 interface add uap0 type __ap service dnsmasq restart sysctl net.ipv4.ip_forward=1 iptables -t nat -A POSTROUTING -s 192.168.50.0/24 ! -d 192.168.50.0/24 -j MASQUERADE ifup uap0 hostapd /etc/hostapd/hostapd.conf
interface=uap0 #driver= # The name for the AP. Can include spaces, like "Inconspicuous Rock". ssid=your_ap_wifi_network_name #country_code=US hw_mode=g channel=11 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 # Comment out the wpa* group below if you # want to run an open network. wpa=2 wpa_passphrase=the_password_for_this_network wpa_key_mgmt=WPA-PSK wpa_pairwise=CCMP wpa_group_rekey=86400 ieee80211n=1 wme_enabled=1
# I had to change this from 1 to 0, because avahi # wasn't running on start (probably failing early). # This was key to be able to access the Pi via # its "{hostname}.local" address on the network. AVAHI_DAEMON_DETECT_LOCAL=0
is this configuration still working on Raspberry Pi 3 model B? I have struggled for this for a weeks until now