Did you know that the
Now, we’re going to be honest and tell you upfront that with some of the entry level
Parts List for this Project
Here’s a quick parts list for this project to get you started quickly:
- Raspberry Pi 3
- Raspberry Pi power supply
- Raspberry Pi case (case with fan)
- 32GB microSD card
- Ethernet cable
- Wireless keyboard
How to Setup a
Raspberry Pi as Wireless Access Point
Now let’s move on and learn how to setup a
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.
NAT vs. Bridging RPi Access Points
Before we begin, we need to explain something. There are two ways to setup a
- 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
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.
Configure DHCPD and Interfaces for Bridge Mode
In order to turn our
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
# 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:
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.
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
Connecting to Your
Raspberry Pi Wireless Access Point
On any device except your
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
Now there are definitely some cons to using a
- 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