Raspberry Pi Wifi Repeater

I have an old iPad which has been dropped so many times that a piece of wire fell out the side, and I think that wire was the wifi antenna.   The iPad can only connect to wifi when it’s close to the access point or when the signal is very strong.    I figured out that my young daughter could still use it in the kitchen, far from the router, if I put a wifi repeater in the kitchen.   As it turns out, this also extends wifi to the back patio, which is an added bonus.

I originally used an old Raspberry Pi 1B for this.  It runs headless, with 2 USB wifi dongles, and sits under a cupboard just like lots of other modern appliances.  But I’ve also tried this out with models 2B and 3B.    The model 3B has an internal wifi interface, so you only need to add one extra USB dongle.

A few years ago I originally set up a Rpi as a wifi repeater using instructions from user Dryfire117 on pastebin1.  Now that I am going through it again, I find that I’m able to simplify things in several ways.   For one thing, with Raspbian Stretch  there is now support for nl80211 in hostapd, so you do not have to rebuild that from source.    Also, I let NetworkManager handle the upstream connection to the internet, which it does very well, so we only do manual configuration for the second wifi interface.   You can use either wifi or wired ethernet for the upstream connection, and it “just works”  because of NetworkManager.

I’ve broken this up into several separate pages, because some of these steps are useful for related projects that I’ll be developing soon.   Here are the key steps:

  1. Setup a new SD card

    After flashing a new Rasbpian Stretch image on an SD card, boot it up and perform the “usual” set of configuration steps, as describe in “Raspberry Pi Initial Configuration

  2. Configure Network

    1. The first wifi adapter, called wlan0, will be used to connect to the Internet or at least in that direction. We’ll call this the “upstream” connection. To configure this network, add an entry for it in the file /etc/network/interfaces (or in a separate file in the directory /etc/network/interfaces.d) You have to decide if you use DHCP (easiest, if you can) or have to specify the IP address and netmask and gateway. Here’s an example for the latter:
      auto wlan0
      allow-hotplug wlan0
      iface wlan0 inet static
        address 192.168.1.99
        network 192.168.1.0
        netmask 255.255.255.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        wpa-ssid "UpstreamSSID"
        wpa-psk "PassWordGoesHere"
        wpa-group TKIP CCMP
        wpa-key-mgmt WPA-PSK
      

      An alternative to wifi is to use a wired connection via ethernet cable using DHCP. Here’s an example:

      auto eth0
      allow-hotplug eth0
      iface eth0 inet dhcp
      
    2. We will manage and control the other wifi network, using wlan1, so add the following lines to /etc/network/interface (or to a file you create in the subdirectory /etc/network/interface.d):
      auto wlan1 
      allow-hotplug wlan1 
      iface wlan1 inet static
        address 192.168.47.1
        network 192.168.47.0
        netmask 255.255.255.0
        broadcast 192.168.47.255
        gateway 192.168.47.1


      Unlike Dryfire117’s instructions, we don’t add anything to this file about the other interfaces, so that they can be managed by NetworkManager.   NetworkManager only manages interfaces NOT mentioned2 in /etc/network/interface, or /etc/network/interface.d, so be sure not to mention the others.

  3. Install and configure hostapd

    The good news is that the version of hostapd distributed with Raspbian Stretch now supports nl80211, so you no longer have to build hostapd from source code anymore.

    There are still a number of steps required to configure hostapd.  Follow these detailed instructions.

  4. Set up DHCP server

    The DHCP daemon is what assigns IP addresses to the computers that join your private network.   Follow these detailed instructions.

  5. Configure routing tables

    Everything so far sets up an access point. Now we also need to configure the routing tables and default route. Follow these detailed instructions.

References

  1. “How to: Make a Raspberry Pi Powered Wifi Repeater” by Dryfire117,  https://pastebin.com/A4jUp2Nq
  2. See https://wiki.debian.org/NetworkManager#Wired_Networks_are_Unmanaged
Print Friendly, PDF & Email