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. We will let NetworkManager handle eth0 and wlan0 and routing to the Internet.   To configure these, give the command
      $ sudo raspi-config
      and set the following:

      • 2 Network Options:
        • N1 Hostname: It’s useful to use the same name for hostname and the SSID of the AP
        • N2 wifi: If you are connecting to the Internet via wifi, then enter the SSID and password for the “upstream” network.
        • N3 Predictable Network Interface Names2 DISABLE this (set it to NO) so that you get back simple interface names like “wlan1“.

        Either the wired ethernet interface or the first wifi interface (or even both) will connect upstream automagically.

    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 mentioned3 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

Print Friendly, PDF & Email