söndag, november 27, 2011

TP-LINK 3420 + OpenWRT + Huawei E398 = 3G WiFi AP

Update on 2012-03-17: the latest firmware supports this out of the box, no need for manual modeswitching and such.

Here is the path that I followed to get my wireless access point up and running. So far I havn't got more throughput than ~7Mbit and this is probably due to the serial interface, there is supposedly a network interface available on the E398 but that is another story.

Edit: when running a throughput test on my laptop I got ~15Mbit compared to the lower number that I recieved on my IPad. Which means I won't bother to tune any parameters performance wise.

  1. Install OpenWRT on the router, I used the upgrade function which works great.
  2. Use telnet to log in to the router, set a root password. Disable firewall to be able to log in through WAN port on router (as you need internet access from the router as well as administration access through SSH from your computer).
    /etc/init.d/firewall stop
    /etc/init.d/firewall disable
  3. Make sure the router has internet access, I used internet sharing on my internet connected laptop and the WAN port of the router.
  4. Find the IP address of the router (which in my case is distributed from my laptop), I used PowerShell.
    1..255 | foreach-object { (new-object System.Net.Networkinformation.Ping).Send("192.168.137.$_", 10) } | where-object { $_.Status -eq "Success" } | select $_.Address.Address
  5. Connect to the router using Putty or some other SSH client. Install the following packages through the opkg tool; comgt (3g scripts), usb-modeswitch (used to switch the mode on the modem from storage to modem), kmod-usb-serial (to be able to use the modem as a serial device).
    opkg install comgt
    opkg install usb-modeswitch
    opkg install kmod-usb-serial
  6. Add the usb-modeswitch command to be run on startup through /etc/rc.local. Add the following line:
    usb_modeswitch -v 12d1 -p 1505 -M "55534243123456780000000000000011062000000100000000000000000000"
  7. Make sure the device that pops up on modeswitch is recognized as a serial device, add the following line to /etc/modules.d/60-usb-serial
    usbserial vendor=0x12d1 product=0x1506
  8. Last but not least create an interface configuration for this new connection by adding the following to /etc/config/network
    config interface wan
            option ifname   'ppp0'
            option proto    '3g'
            option device   '/dev/ttyUSB0'
            option apn      '4g.tele2.se'
            option pincode  0000
            option auto     1
  9. If you wan't this connection to start on boot the auto flag is NOT enough, you can work arround this bug by adding the following script /etc/init.d/network3g
    #!/bin/sh /etc/rc.common
    
    START=41
    STOP=91
    
    start()
    {
        include /lib/network
        scan_interfaces
        for ifc in $interfaces; do
            config_get ifproto "$ifc" proto
            config_get ifauto "$ifc" auto
            [ "$ifproto" = "3g" ] && {
            case "$ifauto" in
                    1|on|enabled) ifup $ifc;;
            esac
            }
        done 
    }
    
    stop()
    {
        include /lib/network
        scan_interfaces
        for ifc in $interfaces; do
            config_get ifproto "$ifc" proto
            [ "$ifproto" = "3g" ] && {
                ifdown $ifc 
            }
        done 
    }
  10. Then configure WIFI etc. Remember to enable the firewall...

I rather like this little setup. The router cost me about 30€ and the mobile plan, including modem, is 17€. Big thanks goes to:

14 kommentarer:

Marcus sa...

I'm also running Tele2 4G and your setup looks nice. I have concern about the throughput though.
When dongle is connected to PC directly I typically get 40-50Mbps and one time even 90Mbps.
What is you max throughput when dongle is directly in PC?

Unknown sa...

Hi Marcus, if you look at my previous post you can see that i got atleast 50Mbit/s. Which is a bit more than the 15Mbit that I'm paying for. I am so far very happy replacing my ADSL with this LTE connection.

Marcus sa...

Yes, LTE is working great here too.

I'm paying for the 80Mbps. So I would like to know what throughput I can expect if I go with your setup.

Do you get 50Mbps throughput with TP-LINK 3420? I just want to make sure before I order one myself.

I know that some cheap routers has limited cpu resources.

Unknown sa...

Have a look at my next post. I can't say whether or not it will cope 80Mbit/s, it seems Tele2 has decided to put up a speed limit for me.

Anonym sa...

I think there's one error:

usb_modeswitch -v 12d1 -p 1505 -M "55534243123456780000000000000011062000000100000000000000000000"

should be:


usb_modeswitch -v 12d1 -p 1506 -M "55534243123456780000000000000011062000000100000000000000000000"

right? ProductId is 1506, not 1505.

Unknown sa...

Hi anonymous

I'm actually correct, it is the exact code that I use. I use product id 1505 and it works.

Anonym sa...

I tried this 'guide' now for like 3 hours and i cant get it work =/
im an noob on computer so please help! :)

Unknown sa...

Hi anonymous

At which point do you run into trouble? Can you verify any of the steps involved, are you able to install OpenWRT on the router?

Anonym sa...

First, I dont know wich openwrt i should install, i tried 2 diffrent but i cant get it work anyway. and what do u mean with "/etc/init.d/firewall stop" etc? should i type it in somewhere or?.. Hehe as u notice im not so good at computers, thanks for the help.

Unknown sa...

Well... if you don't know exactly what you are doing I would discourage you to continue. The steps described here in particular and related to OpenWRT in general require some amount of computer knowledge or you may render the router unusable.

You need the .bin file. The commands are executed through a secure shell connection on the router.

Daniel Holm sa...

Hi,

It felt rather ironic when I whent googling around and round up here, where you linked to me. Haha!

Anyways, thanks for the guide.

But I flashed my router to the latest snapshot (29 Feb 2012) and the modem worked directly. I only installed these packages:
comgt, kmod-usb-serial-option, kmod-usb-serial-wwan, kmod-usb-serial, luci-proto-3g, usb-modeswitch-data and usb-modeswitch.

It just came flying up after I've set all the needed data from Luci and then ran ifup wan via SSH.

Unknown sa...

Hello Daniel

You are absolutely right! I upgraded my device with the latest firmware and flushed all settings, then followed your instructions and it (the 3G interface) popped up alright. The only thing missing now is the fact that my device won´t forward trafic from LAN to WAN, seems like a firewall setting and will look into that tomorrow. Thank you for pointing this out.

Cuzin B sa...

Hello,
Thanks for your tutorial, it's the best I've found so far.
Unfortunatelly, it doesn't quite work on my TP-Link wr1043nd...it returns the following error:


[ 10.320000] usbserial_generic 1-1:1.1: Generic device with no bulk out, not allowed.
[ 10.330000] usbserial_generic: probe of 1-1:1.1 failed with error -5

--- which hasn't been documented so far (or I can't find it).
Could you please help?
Thanks in advance!

Bogdan

Unknown sa...

Hi Bogdan

First of all the specs of your device looks very nice! Unfortunately I have no experience of this device. According to the OpenWRT wiki it's supported although it seems a bit shaky. Have you tried the different versions available? The information that I can find regarding this message points towards the serial device identifier (vendor and product passed to usbserial).