39

When using the Ethernet and a wireless adapter, is it possible to set up the device as a wireless router? If so, what software (and/or additional hardware) would be needed?

  • You will first need some 'wireless' hardware, as the Pi doesn't come with Wifi. But I'm not sure USB dongles can act as access points... If I'm correct, you'll actually need to get some Wifi router. And then I don't really see why you'd want to use the Pi as the router, instead of the dedicated hardware... – Xavier Nodet Jul 31 '12 at 0:14
  • Why not install the version of OpenWRT for the rpi? – user1331 Aug 30 '12 at 4:47
  • I don't see the point of this TBH. The RPi + a WiFi dongle won't be much cheaper than a far superior regular router... – Alexander Sep 2 '12 at 5:29
  • "Cheaper" isn't the point. Yeah, a dd-wrt compatible router may offer more simple functionality for cheaper than this, but isn't part of the point of the Raspberry Pi to explore new was of doing things with computers since it's suddenly possible to put a full-fledged computer in all kinds of places? – ramblinjan Sep 2 '12 at 22:49
  • 1
    I don't think you need a lot of CPU to route packets. The Raspberry Pi has better hardware in terms of raw compute and RAM than most routers (typically routers run at 300-500MHz, with 16-128MB RAM) – Hengjie Dec 31 '12 at 22:46
19

In principle, yes. You can follow any tutorial for setting up a Linux PC as a router.

Useful Tutorials

  • 3
    I will improve this answer when I get a RPi. – Alex Chamberlain Jun 13 '12 at 19:43
  • 13
    Thank you for the information, but I suspect "yes" isn't really what the author was going for here. Providing a link to send the user elsewhere is somewhat counter-productive to this site. It's really early in this site's development. Links alone may provide a short-term solution to the one author, but it does little to bring people into this site. Such answers also make it that much less likely other users will provide a proper answer themselves. – Robert Cartaino Jun 13 '12 at 21:04
  • 1
    Also, the question is for a wireless router. Which I'm pretty sure isn't possible as the RPi can't broadcast wirelessly. – Jivings Jun 13 '12 at 21:10
  • 2
    @Jivings: Source? Should depend on the USB adaptor. – Alex Chamberlain Jun 13 '12 at 21:11
  • 2
    @RobertCartaino I hope to improve the answer, but don't have access to an RPi right now. Instead, I hope this answer gives people hints to try themselves. – Alex Chamberlain Jun 13 '12 at 21:12
7

I'll show steps for Arch Linux because that's the distro I'm familiar with, but instructions for Raspbian shouldn't be very different.

Note that not all wlan0 interfaces support AP mode.

The setup would be

(eth0)<---RPI--->(wlan0)

where the RPI is the router (and AP) providing wireless internet from ethernet.

Install needed software and drivers.

pacman -S wireless_tools wpa_supplicant hostapd

Build the Router.

Build the AP

Edit /etc/hostapd/hostapd.conf (self explained). Start it with rc.d start hostapd and add it to the Daemons array if you want it to start when you boot the RPI.

The wireless router should be now working.

3

From my experience of trying to getting my Raspberry Pi working with a RTL8188CU based tiny wifi dongle, there are more troubles than you thought.

The major difference here is: The power supply of pi's onboard usb is not enough, since each usb limits to 140mA on pi. While this is enough for using the pi as a "client" connecting to real wifi routers, it is usually not enough to act as one. Although one could probably put the dongle into master mode, it could be very unstable. A possible solution is to bypass the poly fuses. But I have not tried that.

Even if the power supply is enough, the linux driver for the wifi dongle is the next problem. The driver in the "official linux kernel" cannot put my dongle as a client. I had to download a driver from Realtek website (the script here is very helpful). Then a program called hostapd is needed to make it a working AP. Someone failed on that. I didn't succeed either, even on a desktop with latest arch linux.

In the end, I just gave up. I suggest buying a proper wireless router is the way to go. The pi is just not designed for this kind of task.

  • Bypassing the polyfuses work, however you'd need to make sure you use a 1ohm resistor to do the bypass to ensure that there is a small amount of resistance to prevent the Pi from crashing. – Hengjie Jan 1 '13 at 8:35
  • Using an rtl8188 chip might have failed anyway, as the drivers don't have nl80211. – XTL Jan 9 '13 at 9:45
3

Easily with the RALink RT5370, which works straight in the Pi even with the polyfuses.
I got hostapd installed, set a static IP address on my wifi interface, then setup hostapd with ssid and psk.
Then I used dnsmasq to hand out IP addresses and it worked ok for me.

Full instructions here on my blog - http://sirlagz.net/?p=589

  • This is a dead link! – Sean Bone Aug 30 '12 at 7:57
  • @SeanBone The link is not dead for me – 8128 Aug 30 '12 at 7:59
  • I don't mean actually dead, but this is all I get: Warning: fopen(/home/sirlagzn/public_html/wp-content/GeoIP/GeoIP.dat) [function.fopen]: failed to open stream: No such file or directory in /home/sirlagzn/public_html/wp-content/plugins/statpress-visitors/GeoIP/geoip.inc on line 399 Can not open /home/sirlagzn/public_html/wp-content/GeoIP/GeoIP.dat – Sean Bone Aug 30 '12 at 8:02
  • @fluteflute so it's effectively dead... – Sean Bone Aug 30 '12 at 8:04
  • Mind you, it gives me the same errors if I simply go to sirlagz.net – Sean Bone Aug 30 '12 at 8:07
2

Yes, it is definitely possible and there are SD images ready for it: http://www.pi-point.co.uk/

1

In addition to the good points in the other answers: get a WiFi device with good Linux support. You want one that works in access-point or managed mode. Many devices do not work in this mode in Linux, even if they work fine as a client. How well a device works depends on the state of the device driver. Before you buy anything, check the state of the various drivers at linuxwireless.org. Choose a driver with good support (at least the AP mode), then find a device containing that chip.

I got a TL-WN722N USB device supported by the ath9k_htc driver. This works very well with hostapd and WPA2 encryption. I wrote a blog post on my wlan router setup here. Regarding the CPU demands mentioned in the comments of the question: I have not had problems with high CPU load. With iperf, I measured 22 Mbit/s throughput over WLAN from a laptop to the Pi, when the connection speed was reported as 54 Mbit/s. I don't quite know how much one can expect, or where the bottleneck is in my setup.

0

Yes, it is possible, and there are now projects that have done this sort of thing for you, so all you have to do is load a distro (just like Raspbian). There are also a lot of other networking related projects you may want to consider.

It's also possible to set up the Pi to act as a more advanced router to do fancy things like route your traffic through a VPN and/or Tor. Adafruit wrote a how-to guide back in the day, calling their project 'Onion Pi'. Lifehacker gives a detailed how-to on turning the Pi into a VPN proxy.

Sadly, pfSense will not get ported to the Pi, at least the way I interpolate their message boards. it makes sense though, since the networking on the Pi is based off of USB.

There are also other SBC projects that take different approaches (Beaglebone), and travel routers that do similar things (Invisibox, Anonabox, P.O.R.T.A.L., etc.).

Now that the Pi 3 is out, I can imagine we'll see some interesting developments in this area. As it turns out, you can improve the speed of your Pi with a USB Gigabit adapter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.