Configure Raspberry Pi as WiFi Router

Raspberry Pi Logo

Raspberry Pi embarking on a journey to routerhood.


Now that we have the Kindle and the Pi talking to one another via Remote Desktop
everything is great, right?

Well not exactly.

What if we are in a remote location where we have no WiFi?

Surely in that weird situation we’d want to blog about how we wound up in the
wilderness, right?

The problem is that without a WiFi router, our two devices can’t talk to each other.

“But, wait!” you say. “How about an ad hoc network?”

That should be the answer, but unfortunately the Kindle Fire HD cannot connect to
another device via an ad hoc network. (That means two devices connecting directly
to one another via WiFi without a router.)

Fortunately, the Raspberry Pi can act as a router itself.

Many routers on the market are actually just little Linux computers running
routing software.

Warning
If you follow this plan you will NOT be able to use your Pi to connect to a WiFi router!
You are telling your Pi to be a router.

Having said that, I will likely later either buy a second WiFi dongle or write scripts to
switch modes.

Since this is a Pi we’re talking about, maybe I’ll make a physical switch!

I know I said all this in the first post in this series, but I’m also saying it here
BEFORE you break your Pi’s ability to connect to WiFi!

I don’t want to re-write the wheel here, so I’ll just summarize the steps, but point you
to How-To: Turn a Raspberry Pi into a WiFi router
for full details.

Giant Caveat!!

The version of HostAPD linked from that site is no longer working.

You will have to take a big old detour through “download source from Realtek and compile it yourself”-ville.

You will also likely have to add symlinks in rc2.d before you can successfully complete the setup.




Quick Summary Of Steps


  1. Install hostapd


    Note: You’ll have to build this from source to work on the Pi. Be prepared to wait around for a bit…



    Also **Don’t Use The source file recommended in the write up! You need to go to the Realtek site and
    download the newest version.


    Details are in the AdaFruit Forums.


    > Download and compile the latest drivers from
    > http://www.realtek.com.tw/downloads/dow … Down=false Choose the RTL8188CUS.


  2. install isc-dhcp-server



  3. Configure ISC-DHCP-Server



  4. Configure HostAPD



  5. Enable NAT



  6. Start Router



  7. Set Pi to start router on boot


    This is the point at which you’ll need to add your symlinks as described in the RaspberryPi.org forums
    Essentially you’ll need to add sudo ln -s /etc/init.d/hostapd /etc/rc2.d/S02hostapd



If all goes well and you’ve made the appropriate sacrifices to the WiFi gods, then
you should be able to connect your Kindle to your Pi with no additional router needed.

If you are travelling to a hotel with wired, but not wireless internet, your trusty
Pi can get your various devices some WiFi love as well.