Black Lives Matter - Action and Equality.
0

Raspberry Pi Zero W as Access Point
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

Raspberry Pi Zero W as Access Point

by marine_hm on Thu May 21, 2020 9:58 pm

The Adafruit tutorial for Raspberry Pi as an access point is no longer applicable (At least to my knowledge). It did not work for me.
The current version of Raspbian is (BUSTER). I have successfully installed the necessary software and created my own STANDALONE Access Point on my Raspberry Pi Zero W.

Copied from Raspberry Pi.org (access point - ROUTED) I cut out most of the explanations to make it a "direct-to-the-point" GoBy.
Code: Select all | TOGGLE FULL SIZE
Assign Pi as an access point
05-19-20 Raspbian Buster

Setting up a Raspberry Pi Zero W as a STAND-ALONE Access Point

[b]INSTALL THE ACCESS POINT AND NETWORK MANAGEMENT SOFTWARE[/b]
In order to work as an access point, the Raspberry Pi needs to have the hostapd access point software package installed:

sudo apt install hostapd

Enable the wireless access point service and set it to start when your Raspberry Pi boots:

sudo systemctl unmask hostapd
sudo systemctl enable hostapd

In order to provide network management services (DNS, DHCP) to wireless clients, the Raspberry Pi needs to have the dnsmasq software package installed:

sudo apt install dnsmasq

Finally, install netfilter-persistent and its plugin iptables-persistent. This utilty helps by saving firewall rules and restoring them when the Raspberry Pi boots:

sudo DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent

Software installation is complete. We will configure the software packages later on.


[b]SET UP THE NETWORK ROUTER[/b]

Define the wireless IP configuration: The Raspberry Pi runs a DHCP server for the wireless network; this requires static IP configuration for the wireless interface (wlan0) in the Raspberry Pi. The Raspberry Pi also acts as the router on the wireless network, and as is customary, we will give it the first IP address in the network: 192.168.0.41  To configure the static IP address, edit the configuration file for dhcpcd with:

sudo nano /etc/dhcpcd.conf

Go to the end of the file and add the following:

interface wlan0
    static ip_address=192.168.0.41/24
    nohook wpa_supplicant


[b]CONFIGURE THE DHCP AND DNS SERVICES FOR THE WIRELESS NETWORK[/b]
The DHCP and DNS services are provided by dnsmasq. The default configuration file serves as a template for all possible configuration options, whereas we only need a few. It is easier to start from an empty file.  Rename the default configuration file and edit a new one:

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf

Add the following to the file and save it:

interface=wlan0 # Listening interface
dhcp-range=192.168.0.42,192.168.0.62,255.255.255.0,24h
                # Pool of IP addresses served via DHCP
domain=wlan     # Local wireless DNS domain
address=/mqtt.wlan/192.168.0.41
                # Alias for this router

The Raspberry Pi will deliver IP addresses between 192.168.0.42 and 192.168.0.62, with a lease time of 24 hours, to wireless DHCP clients. You should be able to reach the Raspberry Pi under the name PiCharts.wlan from wireless clients.


[b]ENSURE WIRELESS OPERATION[/b]
To ensure WiFi radio is not blocked on your Raspberry Pi, execute the following command:

sudo rfkill unblock wlan

This setting will be automatically restored at boot time. We will define an appropriate country code in the access point software configuration, next.  Configure the access point software
Create the hostapd configuration file, located at /etc/hostapd/hostapd.conf, to add the various parameters for your wireless network.

sudo nano /etc/hostapd/hostapd.conf

country_code=US
interface=wlan0
ssid=MYSSID
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=PASSWORD
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

[b]RUN YOUR NEW WIRELESS ACCESS POINT[/b]
Now restart your Raspberry Pi and verify that the wireless access point becomes automatically available.

sudo systemctl reboot

Once your Raspberry Pi has restarted, search for wireless networks with your wireless client. The network SSID you specified in file /etc/hostapd/hostapd.conf should now be present, and it should be accessible with the specified password.

If SSH is enabled on the Raspberry Pi, it should be possible to connect to it from your wireless client as follows, assuming the pi account is present: ssh pi@192.168.0.41 or ssh pi@mqtt.wlan

REBOOT YOUR RASPBERRY PI!

congratulations on your new access point!

marine_hm
 
Posts: 226
Joined: Wed Dec 23, 2015 12:56 am

Please be positive and constructive with your questions and comments.