From charlesreid1

Making a Raspberry Pi a hotspot

See https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

Installing Stuff

sudo apt install dnsmasq hostapd dhcpcd5

Edit dhcpcd config file

Edit /etc/dhcpcd.conf and modify it to contain this:

interface wlan0
    static ip_address=192.168.4.1/24
    nohook wpa_supplicant

replace wlan0 with whatever interface you want to use.

Restart dhcpcd service

sudo service dhcpcd restart

Edit dnsmmasq config file

Edit the dnsmasq config file /etc/dnsmasq.conf, which determines what range of ip addresses will be handed out and for how long. Modify it to contain this:

interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h

This will hand out IPs starting at 192.168.4.2 and ending at 192.168.4.20, lasting for 24 hours lease time.

Modify wlan0 to whatever interface you are using to provide the wifi network.

Restart dnsmasq service

sudo systemctl start dnsmasq
# or
sudo systemctl reload dnsmasq

Edit hostapd config file

Now modify the file /etc/hostapd/hostapd.conf to configure hostapd. Modify the contents to the following:

interface=wlan0
driver=nl80211
ssid=MyLittlePony
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=AardvarkBadgerHedgehog
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Note values for hw_mode are:

  • a = IEEE 802.11a (5 GHz)
  • b = IEEE 802.11b (2.4 GHz)
  • g = IEEE 802.11g (2.4 GHz)

Specify location of hostapd file

Modify the file /etc/default/hostapd to read:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Stupid hostapd doesn't work

 "Could not read interface wlan1 flags: No such device"

https://wireless.wiki.kernel.org/en/users/Documentation/hostapd

Restart hostapd

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd

Check status and ensure running ok:

sudo systemctl status hostapd
sudo systemctl status dnsmasq