Use mobile internet 3g USB dongle as WAN

A collection of tips on howto tweak your Bubba.
Post Reply
psykopatpastorn
Posts: 10
Joined: 05 Jul 2009, 01:05

Use mobile internet 3g USB dongle as WAN

Post by psykopatpastorn » 27 Jul 2009, 15:35

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 :

Code: Select all

auto ppp0
iface ppp0 inet wvdial
6. unplug your WAN network cable if you have one (as you will temporarily disable the firewall)
7.

Code: Select all

/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 ------
Last edited by psykopatpastorn on 29 Jul 2009, 03:27, edited 1 time in total.

carl
Posts: 474
Joined: 07 May 2008, 04:41

Re: Use mobile internet 3g USB dongle as WAN

Post by carl » 27 Jul 2009, 18:01

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
We have also though of the possibility of using an dongle as WAN, so perhaps we will include such feature as this in the future.
/Carl Fürstenberg, Excito Software Developer
http://www.excito.com
support@excito.com

psykopatpastorn
Posts: 10
Joined: 05 Jul 2009, 01:05

Re: Use mobile internet 3g USB dongle as WAN

Post by psykopatpastorn » 27 Jul 2009, 18:16

carl wrote:There are some places which have "eth0" statically defined
Thanks for reminding me!

carl wrote:We have also though of the possibility of using an dongle as WAN, so perhaps we will include such feature as this in the future.
Sounds nice. It would definitely be convenient to have a single WAN interface settings somewhere that controls the whole system.

Harry
Posts: 49
Joined: 12 Feb 2009, 09:43

Re: Use mobile internet 3g USB dongle as WAN

Post by Harry » 28 Jul 2009, 05:56

psykopatpastorn wrote: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 ).
Now this sounds really great, especially since I'm really considering buying a 3g router just for this purpose.

Do You have any experiences/theories of hot swapping the 3g dongle? which would come in handy if I would like to use the 3g dongle out in the field on a regularly frequent basis.

I wonder if I could use my Iphone as a 3g "dongle" for the above? It works great as a 3g "dongle" on an Windows xp PC.

Cheers
Harry

psykopatpastorn
Posts: 10
Joined: 05 Jul 2009, 01:05

Re: Use mobile internet 3g USB dongle as WAN

Post by psykopatpastorn » 28 Jul 2009, 07:10

Harry wrote:especially since I'm really considering buying a 3g router just for this purpose.
I did too, before I realised I should buy a Bubba2 instead. A bit more expensive, but of course you get so much more than a 3g router for the money. Also, I don't trust the 3g router firewall. With iptables, I can see what's going on.
Harry wrote:Do You have any experiences/theories of hot swapping the 3g dongle? which would come in handy if I would like to use the 3g dongle out in the field on a regularly frequent basis.
You mean you want to jerk it out of your bubba2 while it's up and running, and then stick it back in and hope everything will work? I doubt that will work, mostly because wvdial will get an interrupted session, and you don't have anything that will reinitiate it upon re-insertion of the dongle. The risk of hardware or OS damage is minimal (or non-existant even?) though. What I would recommend, is to shut down the bubba, then disattach the dongle. When you get back home, you re-insert the dongle, then boot up the bubba.
Harry wrote:I wonder if I could use my Iphone as a 3g "dongle" for the above? It works great as a 3g "dongle" on an Windows xp PC.
I don't know. Do you connect it to the PC with a usb cable, or is it bluetooth? My intuition says it won't work out of the box, prepare for some configuration.

psykopatpastorn
Posts: 10
Joined: 05 Jul 2009, 01:05

Re: Use mobile internet 3g USB dongle as WAN

Post by psykopatpastorn » 07 Aug 2009, 01:45

I ran into this trouble every 1440 minutes:

Code: Select all

Aug  6 11:05:18 bubba pppd[4297]: LCP terminated by peer
Aug  6 11:05:18 bubba pppd[4297]: Connect time 1440.0 minutes.
Aug  6 11:05:18 bubba pppd[4297]: Sent 18690882 bytes, received 226028192 bytes.
Aug  6 11:05:18 bubba pppd[4297]: Modem hangup
Aug  6 11:05:18 bubba pppd[4297]: Connection terminated.
I don't know whether it's actually peer who terminates the connection, or it's because of some session timeout setting in wvdial/ppp/?, but if you add this line to wvdial.conf, it will reconnect automatically:

Code: Select all

Auto Reconnect = On
There is still one disconnection problem left, which happens more rarely, and which does not seem recoverable by wvdial. Judging from the syslog, it seems like the USB-dongle itself drops out. Then it is rediscovered, and the fake CD-rom-partition (used by the stick for auto-running stuff in Windows) is mounted again, and the modem is reattached to ttyUSB0. By then, though, wvdial seems to have given up on the modem.

Lars akerman
Posts: 7
Joined: 08 Apr 2011, 09:18

Re: Use mobile internet 3g USB dongle as WAN

Post by Lars akerman » 08 Apr 2011, 13:04

Hi,

I tried the guide using my Bubba 2 Wifi and a Huawei e1750 with no success.

I get the following error message:
Cannot open /dev/ttyUSB0: No such file or directory

Anyone know what might be wrong?

I then found the following guide:
http://www.geeksonhigh.com/tag/usb-modeswitch

But it was not able to find and install the "usb-modeswitch" on my bubba 2. Anyone know if this can be done?

I found the "usb-modeswitch" package for Debian Squeeze but not for Debian Etch. Will a Debian Squeeze firmware upgrade soon be available for Bubba 2?
http://packages.debian.org/search?keywo ... modeswitch

Thanks
Lars

vrep
Posts: 22
Joined: 31 Jul 2009, 03:23

Re: Use mobile internet 3g USB dongle as WAN

Post by vrep » 27 Sep 2011, 14:18

I found Sakis3g to be very easy to use:
  • Download sakis3g script from http://www.sakis3g.org. I used the version without the usb_modeswitch, because I had it already installed and because it says on the website that the version with usb_modeswitch doesn't support powerpc.
  • Installation is very simple. Just type: chmod +x sakis3g
  • Get usb_modeswitch via http://www.draisberghof.de/usb_modeswitch/ and install it according to the guide.
  • The only thing you then have to do is copy the proper configuration file for usb_modeswitch from /usr/share/usb_modeswitch/ to /etc/usb_modeswitch.d/. You'll find the proper configuration file by either knowing the usb code (which equals the file name) or just search the file contents for the device you're looking for. Mine was 12d1:1520 for the Huawei K3765.
Next step is to make this automatic as soon as I plug in the modem.

vrep
Posts: 22
Joined: 31 Jul 2009, 03:23

Re: Use mobile internet 3g USB dongle as WAN

Post by vrep » 29 Mar 2012, 17:55

An update with regards to starting the script automatically.

On USB dongle insert:
In the directory /etc/udev/rules.d create a file called 10-sakis3g.rules and fill it with the contect below. To get your usb specific id's, use lsusb.

Code: Select all

bubba:/etc/udev/rules.d# more 10-sakis3g.rules 
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1520", ATTRS{bInterfaceNumber}=="00", RUN+="/usr/bin/sakis3g --debug toggle 2> /var/log/sakis3g.log" 
On start/stop of the system:

Code: Select all

updaterc.d sakis3g defaults

kenned
Posts: 12
Joined: 27 Feb 2011, 13:55

Re: Use mobile internet 3g USB dongle as WAN

Post by kenned » 15 Nov 2013, 19:21

My B3 has been serving up internet from a 4G/LTE USB modem for a while, and all along my easyfind name has not been working.

The problem was that the easyfind script sends the MAC address of the WAN-interface, and since my WAN-interface is now ppp0, which has no MAC address, the easyfind script fails.

To fix it, force the script to use the mac address of the regular WAN-interface (eth0).
Add the following to line 146 in file /usr/share/bubba-backend/bubba-easyfind.tac :

Code: Select all

    WAN = 'eth0'  ## override WAN interface, since ppp0 has no MAC address
And because it's python, it needs the 4 spaces in the beginning of the line! :)

Henri
Posts: 62
Joined: 14 Jul 2009, 07:56

Re: Use mobile internet 3g USB dongle as WAN

Post by Henri » 30 May 2014, 12:11

Hi

I was thinking of trying to get Easyfind working with Bubba 3, which is working as a wireless 4G router at home.
Things did not go as expected. Maybe someone with better understanding of the matter or a working setup can give me some guidance.

I've been following the instructions in this thread and have changed eth0 --> ppp0 in the files specified by Carl's post.

Code: Select all

/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
I noticed that path of bubba-easyfind and firewall_rewrite has changed somewhere in the line and those files were on my B3 at:

Code: Select all

/etc/dhcp/dhclient-exit-hooks.d/bubba-easyfind 
/etc/dhcp/dhclient-exit-hooks.d/firewall_rewrite
Last part where I need to edit easyfind.tac file is blur to me.
How should I edit the python file?
Adding a new line as line 146 with following contents did not work.

Code: Select all

    WAN = 'eth0'  ## override WAN interface, since ppp0 has no MAC address
Web GUI gave the following error after I tried to activate Easyfind service:

Code: Select all

Easyfind failed with following error: Name is not valid.
Server responded: Unable to validate from production.
Adding = 'eth0' to existing line 146 did not work.

Code: Select all

    interface = netifaces.ifaddresses(WAN = 'eth0')
Here is how the file originally looks like (Lines 140-159). Line 146 marked by me.

Code: Select all

    # current WAN interface
    WAN = subprocess.Popen(
        ['bubba-networkmanager-cli', 'getwanif'],
        stdout=subprocess.PIPE
    ).communicate()[0].strip()

    interface = netifaces.ifaddresses(WAN) ## line 146
    if netifaces.AF_LINK in interface:
        mac0 = interface[netifaces.AF_LINK][0]['addr']
    d = httpRequest(
        "https://easyfind.excito.org",
        {
            'key': key,
            'mac0': mac0,
        },
        method='POST',
        headers={'Content-Type': ['application/x-www-form-urlencoded']}
    )
    d.addCallback(easyfind_ip_updated)
    d.addErrback(err)

Gordon
Posts: 1356
Joined: 10 Aug 2011, 03:18

Re: Use mobile internet 3g USB dongle as WAN

Post by Gordon » 31 May 2014, 04:19

Hi Henry,

This howto appears to be outdated on some elements indeed. The easyfind procedure was also changed at some time, to enable users that have their B2|3 sitting behind a ISP router to use easyfind as well.

The current easyfind procedure does not require you to send the value of your current IP address along with the change request. What it does need is the hardware address of eth0 (mac0) and a hardware identification string (key). So you should not change easyfind.tac - in fact the only reason to do so would be to hardcode eth0 in it rather than depend on the script to resolve that from bubba network manager as being the WAN interface (the procedure does actually state eth0 on my B3, even though I use PPPoE and it is in fact ppp0).

For the same reason you should not change eth0 to ppp0 in the easyfind.pl script. The other files seem to be correct, although I don't use any of them. Your biggest concern should be the file /etc/network/firewall.conf though, as this holds your current active firewall configuration and does not only define what may be accessed from the outside but also how outbound traffic should be forwarded to the internet (NAT/Masquerade).

Henri
Posts: 62
Joined: 14 Jul 2009, 07:56

Re: Use mobile internet 3g USB dongle as WAN

Post by Henri » 31 May 2014, 13:31

Thank you Gordon.

I restored easyfind.tac and easyfind.pl files back to their original condition.
Now I can turn on Easyfind from GUI and after pressing button 'Update Easyfind' The GUI gives an Update succesful notification.

The firewall.conf is setup like the creator of this thread Psykopatpastorn in his first post instructed (eth0 are replaced with ppp0 i guess).
I have done basic firewall testing with https://www.grc.com/x/ne.dll?bh0bkyd2 and to my limited knowleadge, firewall should be ok at least for the first 1024 ports i hope...

I have not been able to confirm if the Easyfind address is correctly translated to real IP.
/var/log/syslog gave the following lines after setting up Easyfind:

Code: Select all

May 31 20:00:18 B3 twisted: [HTTP11ClientProtocol,client] Got new IP 'xyz.xyz.xyz.18' which is not the same as the last one 'xyz.xyz.xyz.220'
A little bit later...

Code: Select all

May 31 20:01:18 B3 twisted: [HTTP11ClientProtocol,client] Got new IP 'xx.xyz.xyz.18' which is the same as the last one 'xyz.xyz.xyz.18'
After running easyfind update manually

Code: Select all

root@B3:/etc/network# /usr/lib/web-admin/easyfind.pl
Gives a result.

Code: Select all

{"opcode":1,"record":{"domain_id":"1","content":"xyz.xyz.xyz.220","name":"Easyfind_name.myownb3.com","type":"A","id":"2625"},"error":false,"operation":"Ipupdate"}
I still need to do further test to see if I can get ssh connection to B3 by using easyfind address.
IP address has been replaced with xyz for privacy purpose.

Henri
Posts: 62
Joined: 14 Jul 2009, 07:56

Re: Use mobile internet 3g USB dongle as WAN

Post by Henri » 01 Jun 2014, 03:50

Success !!

Silly me. I could not get Easyfind address work at first, because I tried to use complete Easyfind address with ssh.
Trying with

Code: Select all

ssh user@http://Easyfind_name.myowbb3.com
did not work.

Trying without the http:// part worked fine.

Code: Select all

ssh user@Easyfind_name.myownb3.com
Thank you.

Post Reply