These are my own personal notes on how i setup a Pi Zero W as an access points it is a blatant copy of this: https://gist.github.com/tcg/0c1d32770fcf6a0acf448b7358c5d059 but is just missing a couple of things from: http://imti.co/post/145442415333/raspberry-pi-3-wifi-station-ap and like tcg, this is not intended as a guide but notes as i will invariably have to rebuild this sometime and i have broken biscuits for brains.
this is really just the same info as here https://gist.github.com/gbaman/975e2db164b3ca2b51ae11e45e8fd40a
- flash raspbian lite to sd card
- unplug and replug sd card adapter if necessary to see 'boot' drive
- edit
cmdline.txt
add:modules-load=dwc2,g_ether
after the wordrootwait
- edit
config.txt
and adddtoverlay=dwc2
to the end of the file - create a blank file called
ssh
After doing this:
ssh [email protected]
would not actually work from my Ubuntu 17.04 machine, but it would from my mac - if i didn't have a mac, i'm not sure what i would have done, perhaps had to actually plug it in to a monitor and keyboard :(
If you are somewhere where you can use your computer online but have no details for public wifi (work!) then you can share internet with your mac (i don't yet know how to do this on Ubuntu) very easily using this guide: https://stevegrunwell.com/blog/raspberry-pi-zero-share-internet/
~~That said, after doing all the below I was able to ssh [email protected]
from my ubuntu box - not sure why tbh. ~~~ Ah. of course, i put in my ssid details and connected to the network!
plug in and ssh in, then:
sudo apt-get --yes update && sudo apt-get --yes upgrade && sudo apt-get --yes install vim
That raspian does not ship with vim makes the baby jebus cry :(
also:
sudo apt-get install hostapd dnsmasq
This is purely for my own sanity:
vim ~/.inputrc
and add:
## arrow up
"\e[A":history-search-backward
## arrow down
"\e[B":history-search-forward
sudo vim /etc/network/interfaces
and add:
# 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
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
sudo vim /etc/dnsmasq.conf
and add:
# 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
sudo vim /etc/rc.local
and add:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# 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
sudo vim /usr/local/bin/hostapdstart
and add
#!/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
/etc/hostapd/hostapd.conf
and add:
interface=uap0
#driver=
# The name for the AP. Can include spaces, like "Inconspicuous Rock".
ssid=totallyLegitWifi
country_code=GB
hw_mode=g
channel=10
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=myawesomepassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_group_rekey=86400
ieee80211n=1
wme_enabled=1
sudo vim /etc/default/avahi-daemon
and add:
# 1 = Try to detect unicast dns servers that serve .local and disable avahi in
# that case, 0 = Don't try to detect .local unicast dns servers, can cause
# troubles on misconfigured networks
AVAHI_DAEMON_DETECT_LOCAL=0
sudo vim /etc/default/hostapd
and add:
# Defaults for hostapd initscript
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative
# methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration
# file and hostapd will be started during system boot. An example configuration
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
#DAEMON_CONF=""
# Additional daemon options to be appended to hostapd command:-
# -d show more debug messages (-dd for even more)
# -K include key data in debug messages
# -t include timestamps in some debug messages
#
# Note that -B (daemon mode) and -P (pidfile) options are automatically
# configured by the init.d script and must not be added to DAEMON_OPTS.
#
#DAEMON_OPTS=""
DAEMON_CONF="/etc/hostapd/hostapd.conf"
and:
sudo chmod 775 /usr/local/bin/hostapdstart
Finally:
sudo reboot
Hello @ysr23, I'm trying to do the same with a Raspberry Pi Zero W. What I notice is the high packet loss between client and Rpi. Maybe its hardware is not enough to perform as AP. Did you notice the same?