5

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?

Darth Vader
  • 4,218
  • 24
  • 47
  • 70

1 Answers1

5

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:

  1. Open the dhcpcd configuration file with sudo nano /etc/dhcpcd.con. Go to the bottom of the file and add this line, denyinterfaces wlan0. Exit the file with saving.
  2. Next run sudo nano /etc/network/interfaces and edit the wlan0, 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    
  1. Restart dhcpcd using sudo service dhcpcd restart, reload the configuration for wlan0 by running sudo 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.

Darth Vader
  • 4,218
  • 24
  • 47
  • 70