Did you know that the Raspberry Pi can be a wireless AP?  That’s right!  With just a few commands we can make a Raspberry Pi wireless access point that can be used to share your home internet with all of your devices! This is made especially easy now that the Raspberry Pi‘s come with built in wireless and and Ethernet port.  All of the hardware is built in and we just need to make some simple software configurations.

Now, we’re going to be honest and tell you upfront that with some of the entry level Raspberry Pi‘s this is probably not going to perform that well if you have really fast Internet.  But if you’re Internet connection is 35 megabit or slower then you won’t likely notice anyway.  If you have high speed Internet over about 50 megabit you’ll definitely need to go with a new Raspberry Pi 4 which has USB 3 and Gigabit networking.

Parts List for this Project

Here’s a quick parts list for this project to get you started quickly:

How to Setup a Raspberry Pi as Wireless Access Point

Now let’s move on and learn how to setup a Raspberry Pi as a wireless access point!  We’re going to need to install a few packages and configure them to get our RPi acting like a wireless AP.  If you haven’t already read our guide on installing Raspbian, you may want to that first if your Pi is brand new with a blank micro SD card. It’s a pretty simple process.

RELATED: Installing Raspbian on a new Raspberry Pi

As we mention at the beginning of most every article, we keep these articles updated so that they remain fresh and are accurate for the latest version of the software.  Almost every problem reported to us with out tutorials is due to an old version of Raspbian.  Please take a minute to update your Pi to the latest version before you begin.  You can use the following commands to update your Pi:

sudo apt udpate
sudo apt ugprade

Be sure to reboot your Pi after this by using the sudo reboot command to make sure everything is clean after this upgrade.

We recommend that your Raspberry Pi is connected to wired Ethernet as you perform this setup process.

NAT vs. Bridging RPi Access Points

Before we begin, we need to explain something.  There are two ways to setup a Raspberry Pi wireless access point.  NAT mode and Bridge Mode.

  • NAT mode – The RPi acts as a router and NATs all traffic behind it to a new network.  It acts as a DHCP server, and a DNS server for clients.
  • Bridge mode – The RPi simply passes traffic as-is between your wired and wireless networks.

Most of the tutorials online focus on NAT mode. This is a really bad way to go.  It basically means all wireless devices connected to your Raspberry Pi wireless access point will be invisible to wired devices on your network, as they will all be hidden behind a single IP address.

In our tutorial we’re going to do it the right way using bridge mode.  This is will make your RPi act just like a normal wireless access point and simply pass all traffic between the wired and wireless networks (unless you specifically block something with IPTables).

If you happen to need NAT mode, we will cover that in a future tutorial that will be linked here.

Installing hostapd and bridge-utils

Now its time to actually get to the meat of things and start installing packages.  The first two we are going to install are hostapd and dnsmasq.

  • hostapd – This is the magic bit of software that turns your wireless network card into an access point.  It will do most of the heavy lifting for this project.
  • bridge-utils– This software bridges two network adapters in order to pass traffic between them.

To install these, issue the following commands:

sudo apt install hostapd bridge-utils

You’ll need to answer the confirmation prompt and then the software will install.

setup a raspberry pi wireless access point

 

Configure DHCPD and Interfaces for Bridge Mode

In order to turn our Raspberry Pi into a wireless access point, we need to setup bridging.  Bridging is going to join two network interfaces together so they can pass traffic between them.  Let’s start with modifications to dhcpcd.conf.

Edit dhcpcd.conf as follows:

sudo nano /etc/dhcpcd.conf

You’ll want to add the following lines at the end of the file:

denyinterfaces eth0
denyinterfaces wlan0

This configuration will prevent both ETH0 and WLAN0 from getting addresses from the DHCP client services.  This is important, because we only want our virtual bridge interface BR0 to get an IP address.

Now we need to create that bridge and assign it our two interfaces, along with configuring how it gets its IP address.  Edit the interfaces file with the following command:

sudo nano /etc/network/interfaces

If you’d prefer your Raspberry Pi wireless access point to get its IP address automatically from your router, add the following lines:

# AP Bridge setup
auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0

This will tell our RPi AP to get its IP from the network DHCP server (most likely your router/firewall), and that eth0 and wlan0 are to the bridged interfaces.

If you’d like to use a static IP address, the configuration looks like this (replace with your address and network info):

# AP Bridge setup
auto br0
iface br0 inet static
bridge_ports eth0 wlan0

    address 192.168.1.5
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255

Setting up hostapd

The next step is to setup hostapd to off up our SSID and network to users.  To do this edit the following file:

sudo nano /etc/hostapd/hostapd.conf

And now add the following lines (it should be empty):

interface=wlan0
driver=nl80211
ssid=YourSSIDHere
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=YourWPA2PasswordHere
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Now we need to tell hostapd where its configuration is.  Edit the following file:

sudo nano /etc/default/hostapd

Add the following line to the end of the file:

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

That’s all the heavy lifting, let’s enable and start up the hostapd services!  Enter the following commands:

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd

At this point, you’ll be able to see the SSID being broadcast, as well as connect to it from your smartphone, tablet, or laptop.  However, traffic will not yet pass.

First. we need to enable IP forwarding by editing this file:

sudo nano /etc/sysctl.conf

Uncomment this following line (remove the # sign from the front of the line.

net.ipv4.ip_forward=1

Now we need to add masquerading for the Eth0 interface so that it can pass traffic for others:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

And permanently save it so that it works on reboot:

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

And edit rc.local with following command:

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

and add the following line just above “Exit 0”.

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

Now reboot your Raspberry Pi with sudo reboot to make sure everything takes effect on each reboot.

Connecting to Your Raspberry Pi Wireless Access Point

On any device except your Raspberry Pi, open your wireless settings.  You should see your new wireless network SSID available in your listing.  Connect to it and enter the password you chose in the config file above.

connecting to the raspberry pi wireless access point

It should only take a few seconds and you should be on the network and able to browse the internet!

I was only able to get about 55 megabit with a Raspberry Pi 3 Model B+.  However, with my Raspberry Pi 4 I was able to achieve over 150 megabit!  That’s quite amazing.

Now there are definitely some cons to using a Raspberry Pi as an access point.  Let’s talk about a few of them:

  • It won’t be as fast as a real access point.
  • Limited capacity to handle multiple users.
  • The Pi antenna is limited.
  • No support for MIMO or any other advanced handling of clients.

But there is one huge pro.  Its super cheap and super fast to setup.  If you’ve got a Raspberry Pi sitting around and need to add wireless coverage, it only takes about 5 minutes to get it going.