Use mobile internet 3g USB dongle as WAN

From BubbaWiki
Jump to navigation Jump to search

Use mobile internet 3g USB dongle as WAN
Author: psykopatpastorn

Disclaimer: no guarantees given. If you brick your unit, tough luck. Anyhow, it works neatly for me. I hope I remember all the steps here.
Being a cheapskate, I have cancelled my ADSL internet and use the mobile internet 3g dongle at home. I get 3-4Mbit/s which is sufficient for my needs.
This is how I share the 3g internet connection over my home LAN (and Wifi if you like). The dongle is a Huawei E169 HSDPA USB stick, but it probably works with other dongles too.
If you care about security, start and finish by testing your external firewall (perhaps with some online test like http://www.auditmypc.com ).


#### Preparation phase:
1. stick the dongle into bubba2, let it settle for some seconds
2. apt-get install wvdial
3. copy the file contents at the bottom of this message into /etc/wvdial.conf, replacing any existing content
4. Unless you are using Tre Sweden, edit /etc/wvdial.conf (the INIT3-line and perhaps the PHONE-line is probably enough)
5. add this to /etc/network/interfaces :

auto ppp0
iface ppp0 inet wvdial


6. unplug your WAN network cable if you have one (as you will temporarily disable the firewall)
7. edit the network parameters

/etc/init.d/bubba-firewall stop
cd /etc/network
cp firewall.conf firewall.conf.orig
sed -i 's/eth0/ppp0/g' firewall.conf

8. keep the WAN network cable unplugged, you're switching to 3g wan anyway, and it's not safe as long as you use the modified firewall.conf.


#### Test phase:
1. type wvdial. It should give you some output and initiate a working internet connection. If not, use the output to debug.
2. If it works, send it to background (C-z, then bg) and start the firewall: /etc/init.d/bubba-firewall start
3. you should now be up and running, and your LAN computers should have internet access
4. restart your bubba2 if you like to get rid of the terminal emulator used in this test, just to be sure the wvdial won't go down with it.

#### Production phase:
It should all just work now. The ppp0 network interface is set to auto start in /etc/networking/interfaces and the firewall will start as usual, only now using your modified firewall rules. NB: if you switch back to cable WAN, be sure to restore your firewall.conf from the copy you made and restart the firewall. Well, there it is.

------ /etc/wvdial.conf --------------

Code: Select all
[Dialer Defaults]
Area Code =
Ask Password = 0
Auto DNS = 1
Baud = 460800
Carrier Check = 0
Compuserve = 0
Dial Command = ATD
DialMessage1 =
DialMessage2 =
Force Address =
ISDN = 0
Idle Seconds = 3000
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","bredband.tre.se"
Modem = /dev/ttyUSB0
Modem Type = Analog Modem
New PPPD = yes
Password = ;
Phone = *99#
Stupid Mode = 1
Username = ;

------ end of /etc/wvdial.conf ------

Add this line to wvdial.conf:

Auto Reconnect = On

There are some places which have "eth0" statically defined; Depending on your needs, you might want to update following files:

* /etc/dhcp3/dhclient-exit-hooks.d/bubba-easyfind
* /etc/dhcp3/dhclient-exit-hooks.d/firewall_rewrite
* /usr/lib/web-admin/easyfind.pl
* /usr/lib/web-admin/firewall.pl