Introduction: Raspberry Pi Force Server WAP

In this tutorial, you will be stepped through the process of turning your Raspberry Pi into a Wireless Access Point(WAP) and install the Force Server onto it, and have it run off boot so that you can expand on this in future projects.

----- Details about the Force Server to go here----- (Intentionally left out)

By the end of this Instructable you will be able to simply:

  1. Turn on your Raspberry Pi
  2. Connect to its network
  3. Control it from your phone using the Force app

The following WAP creating tutorial is based on/rewrite on Adafruit's online tutorial linked here.

Step 1: Parts

You will need the following:

  1. A Raspberry Pi
  2. An Ethernet Internet connection for your Raspberry Pi
  3. Wi-Fi adapter which supports AP mode (Adafruit Wi-Fi adapters work)
  4. (Micro) SD Card 4GB Minimum with Raspbian installed on it (there are plenty of tutorials out there on how to do this, just Google it)
    1. SD Card reader if you need to install Raspbian
  5. Power supply for your Raspberry Pi (5V 1~2A)

Step 2: Check Ethernet and Wifi

Before continuing make sure the Ethernet cable is connected in and you can ping out from the Pi.

You will also want to set up your WiFi dongle. run sudo shutdown -h now and then plug in the WiFi module when the Pi is off so you don't cause a power surge. When it comes back up check with ifconfig -a that you see wlan0 - the WiFi module.

Step 3: Install Software

Type the following into the terminal.

sudo apt-get update
sudo apt-get install isc-dhcp-server
sudo apt-get install hosted

Step 4: Set Up DHCP Server

Next we will edit /etc/dhcp/dhcpd.conf, a file that sets up our DHCP server - this allows wifi connections to automatically get IP addresses, DNS, etc.

Run this command to edit the file

 sudo nano /etc/dhcp/dhcpd.conf

Find the lines that say

option domain-name "";option domain-name-servers,;

and change them to add a # in the beginning so they say

#option domain-name "";#option domain-name-servers,;

Find the lines that say

# If this DHCP server is the official DHCP server for the local<br># network, the authoritative directive should be uncommented.

and remove the # so it says

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.

Then scroll down to the bottom and add the following lines

subnet netmask {
	option broadcast-address;
	option routers;
	default-lease-time 600;	max-lease-time 7200;
	option domain-name "local";
	option domain-name-servers,;

Save the file by typing in Control-X then Y then return


sudo nano /etc/default/isc-dhcp-server

and scroll down to INTERFACES="" and update it to say INTERFACES="wlan0"

close and save the file

Step 5: Set Up Wlan0 for Static IP

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

sudo if down wlan0

There's no harm in running it if you're not sure

Next we will set up the wlan0 connection to be static and incoming. run sudo nano /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

iface wlan0 inet static

After allow-hotplug wlan0 - see below for an example of what it should look like. Any other lines afterwards should have a # in front to disable them

Save the file (Control-X Y ) Assign a static IP address to the wifi adapter by running:

sudo ifconfig wlan0

Step 6: 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 nano /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=


If you are not using the Adafruit wifi adapters, you may have to change the driver=rtl871xdrv to say driver=nl80211 or something, we don't have tutorial support for that tho, YMMV!

Save as usual. Make sure each line has no extra spaces or tabs at the end or beginning - this file is pretty picky!Now we will tell the Pi where to find this configuration file. Run

sudo nano /etc/default/hostapd

Find the line #DAEMON_CONF="" and edit it so it says DAEMON_CONF="/etc/hostapd/hostapd.conf"Don't forget to remove the # in front to activate it! Then save the file.

Step 7: Configure Network Address Translation

Setting up NAT will allow multiple clients to connect to the WiFi and have all the data 'tunnelled' through the single Ethernet IP. (But you should do it even if only one client is going to connect)


sudo nano /etc/sysctl.conf

Scroll to the bottom and add net.ipv4.ip_forward=1 on a new line. Save the file. This will start IP forwarding on boot up.

Also run

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

to activate it immediately.

Run the following commands to create the network translation between the ethernet port eth0 and the wifi port wlan0

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

You can check to see whats in the tables with

sudo iptables -t nat -S
sudo iptables -S

To make this happen on reboot (so you don't have to type it every time) run

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

run sudo nano /etc/network/interfaces and add

up iptables-restore < /etc/iptables.ipv4.nat

to the very end.

Step 8: Update Hostapd

Before we can run the access point software, we have to update it to a version that supports the WiFi adapter. First get the new version by typing in


to download the new version (check the next section for how to compile your own updated hostapd) then


to uncompress it. Move the old version out of the way with

sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.ORIG

And move the new version back with

sudo mv hostapd /usr/sbin

set it up so its valid to run with

sudo chmod 755 /usr/sbin/hostapd

Step 9: First Test!

Finally we can test the access point host!


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 TheForceServer 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.

Step 10: 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 commands

sudo service hostapd start
sudo service isc-dhcp-server start

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

sudo service hostapd status
sudo service isc-dhcp-server status

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

sudo update-rc.d hostapd enable
sudo update-rc.d isc-dhcp-server enable

Extra: Removing WPA-Supplicant

Depending on your distro, you may need to remove WPASupplicant. Do so by running this command:

sudo mv /usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service ~/

and then rebooting

sudo reboot

Step 11: Connect and Test

Now that we have the software installed on a Pi, it's time to connect to it and test the connection. I'm using a Windows computer but any kind should work fine. On the Pi, run the command

tail -f /var/log/syslog

to watch the system log data, handy for checking and debugging whats going on! Connect with another computer to the AP you made in the previous step.

Enter the WPA key you specified in the previous step.

In the Pi syslog you should see stuff like this! It indicates that a client connected, at what time and what IP address was given to them.

If you can't connect at all, something is wrong with hostapd

On your computer, open up a Terminal (mac/linux) or Start->Run->cmd to open up a command line. First check what ifconfig (mac/linux) or ipconfig (windows) says. You should have IP address in the range.

Try pinging the Pi, its address is - on windows it will ping 3 times and quit. On mac/linux press Control-C to quit after a few pings. You should get successful pings as seen below. If that doesn't work, something is wrong with hostapd or dhcpd (more likely).

Next try pinging, if this doesn't work but the previous does, something is wrong with dhcpd or the NAT configuration (more likely).

Finally, we'll check that DNS works, try pinging If this doesn't work, something is wrong with dhcpd. If everything is good so far, try browsing the internet, sending email, etc. You are now using your Pi as a Wifi Router!


Its possible to set up your router for open or WEP access, but we don't cover that here (and it's not as secure!) You might want to search around for tutorials such as this one that cover hostapd options.

Step 12: Compiling Hostapd

You may have noticed that one step is downloading a copy of hostapd from and swapping it with yours. In case you want to compile your own, here's how (its easy but not necessary if you are OK with using our binary)

Go to the Realtek downloads page

Download linux 3.4.4_4749

Copy the zip to the SD card using any computer which will place it in the Pi's /boot directory (or somehow get that file onto your Pi)

Boot the Pi from the SD card

sudo mv /boot/ .
mv RTL8188C_8192C_USB_linux_v3.4.4_4749.20121105/ rtl
cd rtl
cd wpa_supplicant_hostapd
cd wpa_supplicant_hostapd-0.8/
cd hostapd

*have a sandwich*when done, hostapd binary is in the directory

Step 13: NOTE: Force Server Is Not Yet Available

The Forcer Server script and the app is currently unavailable.

It should be released soon :)

Step 14: Download and Setup the Force Server


Now is finally, the step where you can download the Force Server to run on your Raspberry Pi.

To do this, simply run the following:

cd ~
git clone

Create a copy of the template to work in

Once git has finished cloning the ForceProject Python repository, run the following commands:

cd Python

Now you have just created a new file with the name from the From here on in, you should edit for your own purposes. The file should be left untouched as it will act as a template with all of the built in delegate functions and boilerplate code already there.

Start your Force Server script on boot

Run the following code, assuming the file names, etc are the same as above:

sudo crontab -e

at the bottom, add the following line:

sudo python /usr/pi/Python/ &

Now press Control-O, Control-X, to save and close the crontab file.

Step 15: Set Up the Force Remote

Now that you have set up the Force Server, you are going to want to set up the remote.

Download the Force app from the AppStore here.

Once it has downloaded, launch the app and tap "Add Controller.." to create a new controller. You can name the controller what you want, and a description is optional. For the IP Address, type in and for the Port type in 5555 (this is the default port). You can change the other settings as you wish. Once you are finished, simply tap save on the top right-hand side of the screen and then tap the controller you just made to start controlling your project.

The app has built in documentation of the data structures of what will be received by the server in your script, which can be accessed through a tile's settings, by long taping a tile in the section tray, or in the "Tile Documentation" section of the app.


pbhound (author)2016-01-28

nice just what I needed! I will be making this weekend

DIY Hacks and How Tos (author)2015-11-27

Cool Raspberry Pi project

About This Instructable




Bio: I am a Independent Software Developer working particularly in Swift, Objective-C, Python, and Java. I work on some personal projects in my spare time and ... More »
More by Jordan Lewis:Raspberry Pi Force Server WAP
Add instructable to: