Raspberry PI WiFi Router (hostapd)

Check WLAN drivers

Check that your Pi sees your USB WiFi dongle


If it is a Realtek chipset RTL8192EU, you will see something like:

Bus 001 Device 004: ID 0bda:818b Realtek Semiconductor Corp.

the 818b indicates the RTL8192EU chipset.

Unfortunately this chipset is currently not ‘officially’ supported by Rasbian, but MrEngman over at raspberrypi.org maintains a good library of drivers (https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=127214).


First be sure of the kernel version you are running:

uname -a

resulted, for me in,

4.4.13-v7+ #894

So i grabbed the driver and installed it with:

wget https://dl.dropboxusercontent.com/u/80256631/8192eu-4.4.13-v7-894.tar.gz
tar xzf 8192eu-4.4.13-v7-894.tar.gz sudo 

sudo apt-get install hostapd


Set up wlan0 for static IP

If you happen to have wlan0 active because you set it up, run

sudo ifdown wlan0

Next we will set up the wlan0 connection to be static and incoming. run

sudo vi /etc/network/interfaces to edit the file

Find the line auto wlan0 and add a # in front of the line, and in front of every line afterwards. If you don’t have that line, just make sure it looks like the screenshot below in the end! Basically just remove any old wlan0 configuration settings, we’ll be changing them up

Depending on your existing setup/distribution there might be more or less text and it may vary a little bit

Add the lines

allow-hotplug wlan0
iface wlan0 inet static
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

Any other lines afterwards should have a # in front to disable them.

After that, re-enable the wlan0 interface and check if you have your IP set it up on interface

sudo ifup wlan0

sudo ifconfig wlan0
pi@nissanpi:~ $ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr e8:4e:06:13:f2:a9
 inet addr: Bcast: Mask:
 inet6 addr: fe80::c318:331c:4663:3977/64 Scope:Link
 RX packets:4311 errors:0 dropped:0 overruns:0 frame:0
 TX packets:8497 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:369129 (360.4 KiB) TX bytes:9830120 (9.3 MiB)

pi@nissanpi:~ $

Configure Access Point

Now we can configure the access point details. We will set up a password-protected network so only people with the password can connect.

Create a new file by running

sudo vi /etc/hostapd/hostapd.conf

Paste the following in, you can change the text after ssid= to another name, that will be the network broadcast name. The password can be changed with the text after wpa_passphrase=

  1. # This is the name of the WiFi interface we configured above
    # Use the nl80211 driver with the brcmfmac driver
    # This is the name of the network
    # Use the 2.4GHz band
    # Use channel 6
    # Enable 802.11n
    # Enable WMM
    # Enable 40MHz channels with 20ns guard interval
    # Accept all MAC addresses
    # Use WPA authentication
    # Require clients to know the network name
    # Use WPA2
    # Use a pre-shared key
    # The network passphrase
    # Use AES, instead of TKIP
– Adafruit wifi adapters driver=rtl871xdrv (may also require a specific hostapd app!)
– Many others (including RT5370) driver=nl80211
To view your USB adaptors:
sudo lsusb
pi@nissanpi:~ $ sudo lsusb
Bus 001 Device 006: ID 05ac:0256 Apple, Inc.
Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter / SMSC9512/9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@nissanpi:~ $
 Now we will tell the Pi where to find this configuration file. Run

sudo vi /etc/default/hostapd

Find the line

and edit it so it says
Don’t forget to remove the # in front to activate it!Then save the file

Finally we can test the access point host! Run

sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf

To manually run hostapd with our configuration file. You should see it set up and use wlan0 then you can check with another wifi computer that you see your SSID show up. If so, you have successfully set up the access point.

You can try connecting and disconnecting from the Pi_AP with the password you set before (probably Raspberry if you copied our hostapd config), debug text will display on the Pi console but you won’t be able to connect through to the Ethernet connection yet.
Cancel the test by typing Control-C in the Pi console to get back to the Pi command line

Finishing up!

OK now that we know it works, time to set it up as a ‘daemon’ – a program that will start when the Pi boots.
Run the following command

sudo service hostapd start

you can always check the status of the host AP server with

sudo service hostapd status

To start the daemon services. Verify that they start successfully (no ‘failure’ or ‘errors’)
Then to make it so it runs every time on boot

sudo update-rc.d hostapd enable

Leave a Reply