Since the Pi 3 has an on-board Wi-Fi adapter is it possible to build a Wi-Fi repeater without using Ethernet as input and without using a Wi-Fi dongle?
-
2Yes, and there are plenty of tutorials out there that cover the topic. Please do some basic research before you ask a question. We are not a search engine. – Darth Vader May 28 '17 at 09:30
-
1Most of the tutorials that are available are based in raspberry pi 2 in which wifi dongles were used hence asked this question – siddhartha subramaniyam May 28 '17 at 09:35
-
Here is a tutorial that I found after about 30 seconds of looking: https://frillip.com/using-your-raspberry-pi-3-as-a-wifi-access-point-with-hostapd/ .You can find many more simply by searching for tutorials about using the Pi 3 as a Wi-Fi access point. – Darth Vader May 28 '17 at 09:40
-
As hinted here in the comments and in the answer, make sure you are searching also for "extender" if that is truly what you want to do. – Sep 24 '17 at 13:39
-
1@Darth Vader I typed "raspberry pi wfi repeater" into a search engine and this page was the top hit. No need to be so unhelpful in your response. Why don't you at least link to one of the tutorials? – wobbily_col Aug 04 '18 at 14:28
1 Answers
I think the reason you found it so hard to find tutorials is perhaps not being specific enough in your search queries. And also not realizing that a Wi-Fi repeater and Wi-Fi access point are quite similar.
I'm going to give you a brief overview of how to do what I think you are after. The important thing to note here is the Wi-Fi chip on the Pi 3, BCM43438, is supported by the open-source brcmfmac driver. This is what allows the repeater/access point functionality.
Here are the basic steps:
You need to install dnsmasq which is the DNS DHCP server. You also need to install hostapad which allows the Wi-Fi chip to be used as an access point. So in the terminal run sudo apt-get install dnsmasq hostapd
.
To ensure the Pi remains connected to the router you need to give it a static IP address. You can do this in your router settings or on the Pi. To do it from the Pi end:
- Open the
dhcpcd
configuration file withsudo nano /etc/dhcpcd.con
. Go to the bottom of the file and add this line,denyinterfaces wlan0
. Exit the file with saving. - Next run
sudo nano /etc/network/interfaces
and edit thewlan0
, to give this result:
allow-hotplug wlan0
iface wlan0 inet static
address 172.24.1.1
netmask 255.255.255.0
network 172.24.1.0
broadcast 172.24.1.255
#wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
- Restart
dhcpcd
usingsudo service dhcpcd restart
, reload the configuration forwlan0
by runningsudo ifdown wlan0; sudo ifup wlan0
.
Configure hostpad
by first running sudo nano /etc/hostapd/hostapd.conf
. The file needs to look like this:
# This is the name of the WiFi interface we configured above
interface=wlan0
# Use the nl80211 driver with the brcmfmac driver
driver=nl80211
# This is the name of the network
ssid=Pi3-AP
# Use the 2.4GHz band
hw_mode=g
# Use channel 6
channel=6
# Enable 802.11n
ieee80211n=1
# Enable WMM
wmm_enabled=1
# Enable 40MHz channels with 20ns guard interval
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
# Accept all MAC addresses
macaddr_acl=0
# Use WPA authentication
auth_algs=1
# Require clients to know the network name
ignore_broadcast_ssid=0
# Use WPA2
wpa=2
# Use a pre-shared key
wpa_key_mgmt=WPA-PSK
# The network passphrase
wpa_passphrase=raspberry
# Use AES, instead of TKIP
rsn_pairwise=CCMP
Now run sudo nano /etc/default/hostapd
, replace #DAEMON_CONF=""
with DAEMON_CONF="/etc/hostapd/hostapd.conf"
. You can then exit the file with saving it.
dnsmasq
now needs to be configured. First run:
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.con
Paste in the file:
interface=wlan0 # Use interface wlan0
listen-address=172.24.1.1 # Explicitly specify the address to listen on
bind-interfaces # Bind to the interface to make sure we aren't sending things elsewhere
server=8.8.8.8 # Forward DNS requests to Google DNS
domain-needed # Don't forward short names
bogus-priv # Never forward addresses in the non-routed address spaces.
dhcp-range=172.24.1.50,172.24.1.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time
Setup IPV4 forwarding:
Run sudo nano /etc/sysctl.conf
, the line #net.ipv4.ip_forward=1
needs to become net.ipv4.ip_forward=1
. Next run sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
, to activate the file.
To ensure the Pi's internet connection is shared to the connected devices run the following commands:
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
So that these stick when the Pi reboots run sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
. Then run sudo nano /etc/rc.local
and above the line exit 0
add iptables-restore < /etc/iptables.ipv4.nat
.
Finally run:
sudo service hostapd start
sudo service dnsmasq start
Which sets the necessary services running and everything should now work.
For more information on what some of these commands are doing you can check this website.

- 4,206
- 24
- 45
- 69
-
1This did not work for me on raspbian stretch with the latest firmware. I'm pretty sure my problem lies with the dhcpcd client. Some notable errors include it saying that it failed to to load all interfaces, and
systemctl status dhcpcd.service
furtermore states that this is because there is already some interface defined in /etc/network/interfaces (which is not the case, as it only contains the wlan0 setup from this answer). Moreover, raspbian complains that dhcpd.service changed on disk and that I should reload it, but reloading does nothing. – rien333 Sep 15 '17 at 13:16 -
The rest of it seems to work however, as
ifconfig
shows wlan0 as up with the right ip address. I can even connect to the Pi from another device (running macOS) without any complaints, but no websites actually. Wifi on on the Pi also stopped being able to load any websites. (although the ifconfig output looks okay, as stated) Any help? – rien333 Sep 15 '17 at 13:19