Turn raspberry pi quickly in an accesspoint

on

I bought a very cheap wifi dongle on ebay. With a ralink rt5370 (get them for 4 euros a piece).

First thing I did edit the /etc/network/interface, that now looks like:

 auto lo
 iface lo inet loopback
 auto eth0
 iface eth0 inet dhcp
 auto wlan0
 iface wlan0 inet static
 address 10.0.0.1
 netmask 255.255.255.0

Now I installed hostapd and dnsmasq

$sudo apt-get install hostapd
$sudo apt-get install dnsmasq

Now do some setup

first the hostapd

edit the file /etc/default/hostapd by uncommenting and eddit the line:

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

Now hostapd will be started at boottime and will read the mentioned configurationfile. But that has to be created first by $sudo vi /etc/hostapd/hostapd.conf

I added these lines (for a full open accesspoint)

interface=wlan0
driver=nl80211
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
ssid=RaspAP
hw_mode=g
channel=8
beacon_int=100
auth_algs=3
wmm_enabled=1

After the hostapd setup I did the dnsmasq setup. $sudo vi /etc/dnsmasq.d/dnsmasq.conf

interface=wlan0
dhcp-range=10.0.0.2,10.0.0.5,255.255.255.0,12h

At last I added a line to /etc/hosts
10.0.0.1 rpi

Now do restart everything (restart services networking,hostapd and dnsmasq).

I took my android phone connected wifi to RaspAp. Opened a browser, typed in http://rpi and… Miracly I got the webpage of the raspberry pi.

WPA2

Now let’s secure the connection with some wpa2.

Therefore I added these lines to the hostapd.conf:

wpa=2 
wpa_key_mgmt=WPA-PSK 
wpa_pairwise=CCMP 
rsn_pairwise=CCMP 
wpa_passphrase=very-secret-password

The passphrase must be a string between 8 and 63 characters.
There are ways to masquerade the passphrase. But I don’t care at this moment.

Who is connected to my access point

$iw dev wlan0 station dump: