44

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?

Alex L
  • 7,605
  • 12
  • 42
  • 53
ramblinjan
  • 4,030
  • 7
  • 33
  • 52
  • 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 00:14
  • 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 02 '12 at 05: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 02 '12 at 22:49
  • Theoretically possible, would need a wifi dongle that supports managed mode. Not sure in practice how it would cope as routing packets is pretty cpu intense. I'd make sure the RAM is split in-favor of the cpu and overclock too turbo. I'd be interested to see the performance if you get it working. – iiSeymour Oct 15 '12 at 19:04
  • 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
  • As a comment, as far as USB dongles go I've seen best success with ralink chips, hostapd and udhcpd. – XTL Jan 09 '13 at 09:46
  • Why not install the version of OpenWRT for the rpi? –  Aug 30 '12 at 04:47

7 Answers7

19

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

Useful Tutorials

Alex Chamberlain
  • 15,530
  • 14
  • 67
  • 113
  • 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
  • 1
    @Jivings there are 6 modes of wifi. The 2 most familiar being master i.e the mode wireless routers use and managed the mode devices use. To change your wireless interfaces mode you run iwconfig mode master however you wireless interface must support that mode. Monitor mode is used for packet sniffing but that's a different story, the moral is know what modes you wireless interface (dongle, card etc) supports. – iiSeymour Oct 15 '12 at 18:59
  • So you did still not get an RPi 4 years later? ("I will improve this answer when I get a RPi.") – Thomas Weller Jul 07 '16 at 11:01
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.

Tomas
  • 273
  • 1
  • 3
  • 11
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.

fqsxr
  • 131
  • 2
  • 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 01 '13 at 08:35
  • Using an rtl8188 chip might have failed anyway, as the drivers don't have nl80211. – XTL Jan 09 '13 at 09: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

Lawrence
  • 2,672
  • 14
  • 14
  • This is a dead link! – Sean Bone Aug 30 '12 at 07:57
  • @SeanBone The link is not dead for me – 8128 Aug 30 '12 at 07: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 08:02
  • @fluteflute so it's effectively dead... – Sean Bone Aug 30 '12 at 08:04
  • Mind you, it gives me the same errors if I simply go to sirlagz.net – Sean Bone Aug 30 '12 at 08:07
  • @SeanBone I don't get any errors/warnings – 8128 Aug 30 '12 at 09:02
  • @fluteflute Ok, tested on other browsers as well, the error only occurs on Opera 12.00 (Win32) on Windows 7 ;) Sorry about the mess! – Sean Bone Aug 30 '12 at 10:16
  • Sorry, some malfunctioning plugins on my blog that I've been trying to fix... – Lawrence Aug 30 '12 at 12:59
  • @Lawrence It's fine to link to your own blog, just make sure that you answer makes readers aware that it's a resource you created. However, this answer would be better if you migrated some of the information here, rather than providing a link. Thanks. – Jivings Aug 30 '12 at 22:56
  • Sorry Jivings, I've updated the original answer now :) – Lawrence Sep 01 '12 at 14:54
2

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

Ceottaki
  • 121
  • 1
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.

Frepa
  • 2,261
  • 19
  • 17
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.

YetAnotherRandomUser
  • 1,120
  • 2
  • 10
  • 34