Instructables

Raspberry Pi as a 3g (Huawei E303) wireless (Edimax EW-7811Un) router

Picture of Raspberry Pi as a 3g (Huawei E303) wireless (Edimax EW-7811Un) router
Aim:

Set up the Raspberry Pi as a wireless router using the Raspbian OS. The internet connection will be provided by a Huawei E303 USB 3g dongle on the safaricom network in Kenya, though the setup should be similar on most Huawei dongles and 3g networks. The wireless access point will be provided by an Edimax Nano USB Wifi adapter.

Power Source -------->RPI ----> Powered USB HUB -----> 3g Dongle
                                           |
                                           |         
                                     Edimax
                                        Wifi


The USB ports of the Pi seem to struggle to provide the power for a 3g dongle, so a powered USB hub is necessary.

After a lot of reading and messing around, I've come up with a step by step guide for setting up my Pi as a wireless internet router. I use this every time I make a fresh setup of Raspbian, which is a fairly regular event. Stumbling round my latest install like a drunken elephant, it never takes me long to screw something up so badly that it's easier just to start from scratch.

As such, this guide assumes that the Raspbian operating system is 'fresh'. It has been tested with the 2012-12-16 release - as soon as I have the time free, I'll update the guide for the newest release. So, the steps I use to set up the 'Pifi' Router are as follows:

This guide and more like it can be found on my blog.
 
Remove these adsRemove these ads by Signing Up
raceface2nd2 months ago
thanks for the nice tutorial!

I have a Problem with to get Clients connected to the eth0 to the Internet.

My iptables-restore file is like following

# Generated by iptables-save v1.4.14 on Sun Feb 2 01:41:20 2014
*filter
:INPUT ACCEPT [105:18135]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [99:22038]
-A FORWARD -i ppp0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i eth0 -o ppp0 -j ACCEPT
COMMIT
# Completed on Sun Feb 2 01:41:20 2014
# Generated by iptables-save v1.4.14 on Sun Feb 2 01:41:20 2014
*nat
:PREROUTING ACCEPT [39:3046]
:INPUT ACCEPT [23:1674]
:OUTPUT ACCEPT [28:2989]
:POSTROUTING ACCEPT [7:1539]
-A POSTROUTING -o ppp0 -j MASQUERADE
COMMIT
# Completed on Sun Feb 2 01:41:20 2014

What ist wrong? DNS seems to work, clients are getting the IP from DNS but no ping, nothing is possible.

Any tipps?

Best regards!

Andy
Happz0r3 months ago
Thanks for the tutorial, but it didnt seem to work for me. I got the AP up and running but my clients were not able to use the Internet connection.

It almost drove me crazy, since I'm a linux noob and I wasn't able to solve this...

Until I realized that there's an error in the Nat script.

You wrote:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEP

Problem is, that at least for me, using a 3G connection, you don't have to forward "eth0"(there is no cable plugged in anyway), but rather forward "ppp0".

So all you got to do is to change
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEP

In

sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
sudo iptables -A FORWARD -i ppp0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o ppp0 -j ACCEP


At least that's what helped me :)
svazquez67 months ago
Hi i have another version to install 3G Modem with Raspberry Pi, it is in Spanish but could help to some who wants to use Google Translate, also if you don't want to use Google Translate it could be easy 'cause it has images to guide... http://www.webonactivo.blogspot.mx/2013/09/raspberry-pi-con-banda-ancha.html
I made this script so you can execute (need internet connection first time to download stuff) and then will configure umtskeeper and 3gsakis, it will make the connection, is working with my carrier Tuenti and huawei k3772 dongle, so you have to modify the line 51 to connect with your setting hope it will be helpfull =)
https://mega.co.nz/#!J9UFiBIZ!VsW4GWTcnqABHAAqG7UayUxz_aVHYlwSbvmowQXD2so
dexxster10 months ago
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

Can you please tell why are you using the eth0 interface and not the wlan0 ? Thanks.


goofygutt11 months ago
Nice tutorial! Had some real problems getting it to work on a Huawei E220 modem, but after updating the modem firmware, no problems =)
Now I want to connect to the pc with the 3g Modem using remote desktop, but this was not so easy as it works a little different from usual DSL internet connections, I guess my operator has some restrictions. Have you tried this?
hadrianus11 months ago
There is also a typo regarding the script
sudo tar -xzvf sakis36.tar.gz
instead of
sudo tar -xzvf sakis3g.tar.gz
kyuzumaki1 year ago
Small typo the command for unzip of utms keeper should be sudo tar -xzvf umtskeeper.tar.gz
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!