Raspbian OS auto wifi hotspot

1 minute read

Published:

Step 1
sudo apt install hostapd


Step 2
sudo systemctl unmask hostapd


Step 3
sudo systemctl enable hostapd


Step 4
sudo apt install dnsmasq


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


Step 6
sudo nano /etc/dhcpcd.conf


Step 7
Add to the end of the file, change the ip address with your favourite

interface wlan0
    static ip_address=192.168.4.1/24
    nohook wpa_supplicant




Step 8
sudo nano /etc/sysctl.d/routed-ap.conf


Step 9

# Enable IPv4 routing
net.ipv4.ip_forward=1




Step 10
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE


Step 11
sudo netfilter-persistent save


Step 12
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig


Step 13
sudo nano /etc/dnsmasq.conf


Step 14
Change the address as you want such as 192.168.5.1, after change the address, you need to change dhcp-range as well

interface=wlan0 # Listening interface
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
                # Pool of IP addresses served via DHCP
domain=wlan     # Local wireless DNS domain
address=/gw.wlan/192.168.4.1
                # Alias for this router




Step 15
sudo rfkill unblock wlan


Step 16
sudo nano /etc/hostapd/hostapd.conf


Step 17
ssid refers to the wifi name, you can change to your favourite wpa_passphrase refers to wifi password, you can change to your favourite

country_code=GB
interface=wlan0
ssid=NameOfNetwork
hw_mode=g
channel=7
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




Step 18
sudo systemctl reboot


Step 19
After reboot, browser the wifi and connect it with your own password
For example, Lai-Pi is the wifi setup by raspberry pi