A while back I was trying to get my tmobile e220 modem running on my nslu2 and I tried everything wvdial / network-manager etc etc but still nothing. Getting it to work was the major foundation to a project I was doing so HAD to be done. I was at my wits end when I stumbled purely by accident a webpage explaining how to do it via UMTS. Here’s a copy of the page for archive purposes only none of it is my work and all credit goes to the author.
Linux & hsdpa/umts/gprs with Huawei E220 USB dongle
This page describes how to connect to the internet via a Vodafone hsdpa/umts/gprs
dongle. I verified that one can also connect to the t-Mobile network
with this modem and a t-Mobile sim. KPN seems to work too. Please note
that using either vodafone, t-mobile and KPN are mostly the same. Only
the username/password and the APN differ.
The dongle I bought is in fact an Huawei E220 HSDPA USB modem which looks like this:
When the dongle is inserted, two devices are created. When it is the
first USB serial device, /dev/ttyUSB0 and /dev/ttyUSB1 are created.
Both of these /dev/ttyUSB*-devices act more or less like a Hayes command-set compatible device.
While you use the first one (ttyUSB0) as a device via which you sent the ppp-data, you can use the other (ttyUSB1) to e.g. ask the modem for the signal quality.
To set things up you need to edit 5 files and create two scripts – the scripts are optional.
In this short how-to I used a Debian system altough other Linux systems should work fine too.
What you’re expected to see
When the device is plugged in you’re expected to see the following appear in the output of dmesg:
[ 1073.909131] usb 1-2: new full speed USB device using uhci_hcd and address 2 [ 1074.067219] usb 1-2: New USB device found, idVendor=12d1, idProduct=1003 [ 1074.067236] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 1074.067248] usb 1-2: Product: HUAWEI Mobile [ 1074.067256] usb 1-2: Manufacturer: HUAWEI Technologies [ 1074.067574] usb 1-2: configuration #1 chosen from 1 choice [ 1074.358664] Initializing USB Mass Storage driver... [ 1074.361247] usb-storage: probe of 1-2:1.0 failed with error -1 [ 1074.361297] usbcore: registered new interface driver usb-storage [ 1074.361307] USB Mass Storage support registered. [ 1074.504154] usb 1-2: USB disconnect, address 2 [ 1075.240141] usb 1-2: new full speed USB device using uhci_hcd and address 3 [ 1075.401219] usb 1-2: New USB device found, idVendor=12d1, idProduct=1003 [ 1075.401237] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 1075.401249] usb 1-2: Product: HUAWEI Mobile [ 1075.401257] usb 1-2: Manufacturer: HUAWEI Technologies [ 1075.401554] usb 1-2: configuration #1 chosen from 1 choice [ 1075.412213] usb-storage: probe of 1-2:1.0 failed with error -5 [ 1075.421353] usb-storage: probe of 1-2:1.1 failed with error -5 [ 1075.423283] usb-storage: probe of 1-2:1.2 failed with error -1 [ 1075.861613] usbcore: registered new interface driver usbserial [ 1075.861672] USB Serial support registered for generic [ 1075.861797] usbcore: registered new interface driver usbserial_generic [ 1075.861804] usbserial: USB Serial Driver core [ 1075.879364] USB Serial support registered for GSM modem (1-port) [ 1075.879495] option 1-2:1.0: GSM modem (1-port) converter detected [ 1075.879710] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB0 [ 1075.879743] option 1-2:1.1: GSM modem (1-port) converter detected [ 1075.879894] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB1 [ 1075.879943] usbcore: registered new interface driver option [ 1075.879950] option: v0.7.2:USB Driver for GSM modems
As you can see, 2 devices were created: ttyUSB0 and ttyUSB1.
Files to create/change:
/etc/ppp/chap-secrets & /etc/ppp/pap-secrets
In these two files you add the following line:
vodafone * vodafone
For t-Mobile change this to:
tmobile * tmobile
For KPN change this to:
KPN * gprs
ppp configuration file
Vodafone: /etc/ppp/peers/pct-hsdpa-3g-huawei-e220-vodafone
user vodafone ipparam vodafoneusbumts connect "/usr/sbin/chat -v -f /etc/chatscripts/pct-hsdpa-3g-huawei-e220-vodafone.chat" noccp noauth noipdefault usepeerdns defaultroute replacedefaultroute
t-mobile: /etc/ppp/peers/pct-hsdpa-3g-huawei-e220-tmobile
user tmobile ipparam tmobileumts connect "/usr/sbin/chat -v -f /etc/chatscripts/pct-hsdpa-3g-huawei-e220-tmobileumts.chat" noccp noauth noipdefault usepeerdns defaultroute replacedefaultroute
KPN: /etc/ppp/peers/pct-hsdpa-3g-huawei-e220-kpn
user KPN ipparam kpnumts connect "/usr/sbin/chat -v -f /etc/chatscripts/pct-hsdpa-3g-huawei-e220-kpn.chat" noccp noauth noipdefault usepeerdns defaultroute replacedefaultroute
Chat-scripts (making the modem connect to the network)
If the SIM you’re using requires a PIN-code to be set before you can
connect, run the following script first. No, you cannot add it to the
chat-script as the modem refuses to authenticate against the SIM if you
already did that.
echo -e "AT+CPIN=1234\r" > /dev/ttyUSB0
Replace ‘1234’ by your pin-code and replace /dev/ttyUSB0 with the device allocated for your modem.
Vodafone: /etc/chatscripts/pct-hsdpa-3g-huawei-e220-vodafone.chat
Vodafone Live (consumer)
TIMEOUT 3 ABORT "BUSY" ABORT "NO CARRIER" ABORT "VOICE" ABORT "NO DIALTONE" ABORT "NO DIAL TONE" ABORT "NO ANSWER" ABORT DELAYED "" ATZ OK ATQ0&FEV1X1S0=0&C1&D2 OK AT+CGDCONT=16,"IP","live.vodafone.com" OK ATDT*99***16# CONNECT ""
Vodafone office
TIMEOUT 30 ABORT "BUSY" ABORT "NO CARRIER" ABORT "VOICE" ABORT "NO DIALTONE" ABORT "NO DIAL TONE" ABORT "NO ANSWER" ABORT DELAYED "" ATZ OK AT+CGDCONT=1,"IP","office.vodafone.nl" OK ATDT*99# CONNECT ""
T-Mobile: /etc/chatscripts/pct-hsdpa-3g-huawei-e220-tmobileumts.chat / KPN: /etc/chatscripts/pct-hsdpa-3g-huawei-e220-kpn.chat
TIMEOUT 3 ABORT "BUSY" ABORT "NO CARRIER" ABORT "VOICE" ABORT "NO DIALTONE" ABORT "NO DIAL TONE" ABORT "NO ANSWER" ABORT DELAYED "" ATZ OK ATQ0&FEV1X1S0=0&C1&D2 OK AT+CGDCONT=16,"IP","internet" OK ATDT*99***16# CONNECT ""
/etc/sudoers
Add the following 2 lines:
ALL ALL=(root) NOPASSWD: /usr/local/bin/umtson ALL ALL=(root) NOPASSWD: /usr/local/bin/umtsoff
/usr/local/bin/umtson
#! /bin/sh DEV=$1 if [ -z "$1" ] ; then DEV="/dev/ttyUSB0" fi /usr/sbin/pppd $DEV call pct-hsdpa-3g-huawei-e220-vodafone
For t-Mobile, replace the ‘pct-hsdpa-3g-huawei-e220-vodafone’ by ‘pct-hsdpa-3g-huawei-e220-tmobile’.
For KPN, replace the ‘pct-hsdpa-3g-huawei-e220-vodafone’ by ‘pct-hsdpa-3g-huawei-e220-kpn’.
/usr/local/bin/umtsoff
#! /bin/sh /usr/bin/poff
Using it
Now it is rather simple.
Connecting
sudo umtson
Or if your modem uses e.g. /dev/ttyUSB1 (& ttyUSB2) instead use:
sudo umtson /dev/ttyUSB1
Disconnecting
sudo umtsoff
Book-keeping
In the Netherlands for pre-paid connections you pay per 200KB. So you
might be interested in how much data you’re sending/receiving.
For that you can use the following 2 scripts.
After each connection they add a line to /var/log/e220-usage.log with the time spent, and how much data sent/received.
/etc/ppp/ip-up.d/umts
#! /bin/sh if [ "$6" == "vodafoneusbumts" ] ; then echo `date +%s` UMTS ON >> /var/log/e220-usage.log echo on-line on UMTS | wall fi
For t-mobile replace ‘vodafoneusbumts’ with ‘tmobileumts’.
For KPN replace ‘vodafoneusbumts’ with ‘kpnumts’.
/etc/ppp/ip-down.d/umts
#! /bin/sh if [ "$6" == "vodafoneusbumts" ] ; then echo `date +%s` UMTS OFF time: $CONNECT_TIME recv: $BYTES_RCVD sent: $BYTES_SENT >> /var/log/e220-usage.log echo off-line from UMTS | wall fi
For t-mobile replace ‘vodafoneusbumts’ with ‘tmobileumts’.
For KPN replace ‘vodafoneusbumts’ with ‘kpnumts’.
It doesn’t work!
- Make sure you use the ttyUSB-device of the modem with the lowest number!
- Sometimes it looks as if al is fine but no data gets through. In /etc/resolv.conf you’ll then see:
nameserver 10.11.12.13 nameserver 10.11.12.14
This seems to be a ppp-problem. Disconnect and retry.