Raspberry Pi as a fancy Wi-Fi hotspot
There are plenty of tutorials on how to make your Raspberry Pi a Wi-Fi hotspot with VPN, bells, and whistles. Unfortunately, I occasionally have to start from scratch after making some silly mistake that breaks everything. That’s why I decided to write this tutorial for myself. Maybe you’ll find it useful too. Let me know if you do!
I am using Raspberry Pi 2 Model B (1,2 GHz Quad-core ARM Cortex-A53, 1GB RAM, USB 2.0) with Raspbian Jessie Lite image from https://www.raspberrypi.org/downloads/raspbian/. See installation guide for Linux (guides for other operating systems should also be available on the website).
Check https://www.linode.com/docs/security/securing-your-server for some information about securing your server.
Making a Wi-Fi hotspot
I was using Edimax EW-7811UN Wi-Fi adapter, which seems to work reasonably well with Raspberry Pi 2.
We need a custom version for this dongle. It’s available at https://github.com/jenssegers/RTL8188-hostapd.
First, delete the old version if it’s installed:
# apt-get autoremove hostapd
Now clone the repo and install it:
# git clone https://github.com/jenssegers/RTL8188-hostapd.git # cd hostapd # make # make install
Now modify the configuration file that has just been created at /etc/hostapd/hostapd.conf.
The only two values that need changing are
# apt-get install dnsmasq
Create configuration file /etc/dnsmasq.conf (replace old one, if exists) and update it with the following values:
interface=wlan0 bind-interfaces server=184.108.40.206 domain-needed bogus-priv dhcp-range=172.24.1.50,172.24.1.150,12h
Add the following two lines at the end of /etc/dhcpcd.conf:
interface wlan0 static ip_address=172.24.1.1/24
In /etc/network/interfaces comment out this line in
In /etc/sysctl.conf uncomment this line:
This should enable forwarding on the next reboot.
To share internet connection on
eth0 to Wi-Fi add the following lines to
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
To start up all the services add:
sudo service hostapd start sudo service dnsmasq start
Next, you need to reboot the Pi:
After it’s up again Wi-Fi hotspot should be available. Success!