Setting up a Raspberry Pi 2 as an Access Point

Recently for work I setup a Raspberry Pi 2 as an Access Point (AP) to compensate for our APs not covering all the gaps and some weird devices that won't connect reliably to our Meraki network (e.g. my Wileyfox Swift). I couldn't find one simple guide that just worked so documenting here in case it's useful. It took a fair bit of playing around to get it working and I altered configuration a few times so tell me if things don't work and I'll try to correct my instructions. I'm assuming that you also have Linux knowledge but do tell me if things are unclear. You don't need to be a Raspberry Pi expert - this was my first project on it.

The simplest way is to buy this Raspberry Pi 2 kit and to add the Raspberry Pi Offical Wi-Fi Dongle. Full disclosure - I will make a (small) amount of money if you buy from those links. You don't have to buy the kit - other Raspberry Pi 2s will work and I'm guessing that the original Raspberry Pi will also work as networking needs very little CPU or RAM. I would strongly recommend using the official wifi dongle though as Raspbian has built in support and you don't have to download extra binary files for hostapd. I did try two other wireless dongles but they just seemed like too much hard work to get going and I always take the lazy and simple solution if I can!!!

I'm assuming that you're using the Raspbian distribution and also that all commands are being run as root. I usually just do "sudo -s" before starting work on configuration. Also make a copy of each file before you edit it doing something like "cp config-file config-file.sav" for when you make a mistake or want to revert.

I set this all up by plugging into a monitor / keyboard / mouse but once completed it ran "headless" just fine.

You can run an AP in one of two modes basically - bridge or router. A router builds a separate network basically and you need to do more configuration e.g. set up routes on other boxes, create a network scheme, setup a DHCP server. A bridge is like a network extension or connecting switches to each other and just passes through packets. Subsequently a bridge is much simpler so guess which option I chose....

So enough talking and here is what you need to do:
apt-get install bridge-utils hostapd
(this installs the bridge tools, and hostapd turns your wireless card into an AP)

You then need to alter /etc/network/interfaces to something like:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet dhcp
# This presumes you don't want to put a static IP on Raspberry

allow-hotplug wlan0
iface wlan0 inet manual
post-up /usr/sbin/hostapd -B /etc/hostapd/hostapd.conf
# Notice the post-up. Other guides saying start hostapd in /etc/init.d or /etc/default didn't work for me. The -B means run as daemon

auto br0
iface br0 inet dhcp

bridge_ports eth0 wlan0
# The dhcp means it gets the DHCP from your network, not locally. the bridge_ports line is what connects your Ethernet to your wireless network

NB when altering this file (and others) check that that eth0 and wlan0 are actually your device names if needed by doing ifconfig -a

Now alter /etc/hostapd/hostapd.conf to something like this

# driver=nl80211
# seems like driver name is not needed


After this is all done, reboot and you should have a working AP.

Like any normal person I used Google to find out a lot of the info so these are sites that I found useful along the way:


Popular posts from this blog

Getting Apple USB Ethernet adapter working with Windows 8.1 (or Windows 10)

How to burn a USB stick for UEFI Windows 10 build when > 4 GB files are present

Setting up a SoftEther VPN server for personal use