I have done this with 2 USB nano wifi adapters. The first challenge is making sure one of the wifi adapters supports "master" mode which is necessary to configure it as a hotspot. Try sudo iwconfig wlanX mode master
on each one. If one of them supports master mode (no error), you're in business. If not, there's no sense continuing until you have one that does.
There are 3 steps involved:
- Configure one of your wifi interfaces as a hotspot. You do this with
hostapd
.
- Configure the other wifi interface to connect to your
Internet connection - presumably some sort of existing network.
- Configure routing or bridging to pass the traffic between the wifi
interfaces. From what you're describing, you probably want routing
with Network Address Translation (NAT) to allow your wifi devices
connecting to the RPi to share its IP address for Internet access.
Dave Conroy has a nice howto, including links to a version of hostapd
modified for the Edimax nano wifi adapter that I use for creating hostspots. His tutorial uses bridged mode, which is suitable for a simple repeater, but you'll want to replace the bridging configuration with a routed+NAT configuration.
None of these steps are particularly hard, but there is one major consideration. The throughput of the cheap wifi adapters is dismal. I found that none of the 3 I tried (Edimax, TP-Link and generic) would provide more than 45-56 Mbps on a full desktop system, despite claims of 802.11n support. In a bridged or routed configuration, I was never able to get more than 10 Mbps of throughput on my 60 Mbps Internet connection. Local tests using iperf
confirmed this. Testing with 2 bridged USB3 1 Gbps (wired) Ethernet showed that the RPi can handle over 100 Mbps throughout, so the problem is the wifi adapters. Performance is mediocre at best.