Raspberry Pi #
Add WiFi AP #
Based on a forum post by pugbot.
1. Update the system … duh'. #
apt update && apt upgrade -y
2. Install necessary software #
We need an access-point daemon and a DHCP service for connecting clients:
apt install -y hostapd dnsmasq
3. Create configuration files #
Do not attempt to edit and interface files as some older guides say. They are not used anymore since
Configure a new static address in
/etc/dhcpcd.conf and prevent
wpa_supplicant from messing with the interface:
Maybe backup the installed
/etc/dnsmasq.conf config for reference and then configure it as follows:
server=192.168.1.1 # upstream dns
#domain-needed # reject short names?
#bogus-priv # reject private address spaces?
Now configure the access-point network in
/etc/hostapd/hostapd.conf. The channel should match the station network but I found that it is changed automatically anyway to follow the current station.
Add the config in the service defaults in
4. Startup script #
Until now the above configuration is not applied on boot. So you can write yourself a startup script to enable the access point (and add it to
/etc/rc.local if you want).
# redundant stops to make sure services are not running
systemctl stop hostapd.service
systemctl stop dnsmasq.service
systemctl stop dhcpcd.service
# recreate uap0 interface
iw dev uap0 del
iw dev wlan0 interface add uap0 type __ap
# modify iptables for routing of clients
iptables -t nat -A POSTROUTING -s 10.56.0.0/24 ! -d 10.56.0.0/24 -j MASQUERADE
# bring up uap0 interface .. uncomment line if using dhcpcd.conf doesn't work
#ifconfig uap0 10.56.0.1 netmask 255.255.255.0 broadcast 10.56.0.255
ifconfig uap0 up
# start hostapd
systemctl start hostapd.service
# start the rest
systemctl start dhcpcd.service
systemctl start dnsmasq.service