Using a GSM mobile phone as a GPRS modem in Linux

My distro of choice is Ubuntu.  When I first worked out how to do this, I was using Ubuntu 5.10 Breezy Badger.  Since then, I’ve upgraded to 6.06 Dapper Drake, and it still works.  As far as I can see, it should work with any Linus distro.  But some distros don’t come with wvdial as standard.  If you’re in that position, check out  You should be able to get the latest version from there
Why would anyone _want_ to use a mobile phone as a modem? Call costs are expensive, connections are unreliable, and data transfer speeds are slow. In these days of high-speed wireless connections, what’s the point?

Well, costs aren’t necessarily that high. True, voice calls can be pretty pricey, but I’m talking about using the phone as a GPRS modem, not regular dial-up. This means that, instead of using the usual voice circuit, we will be using the “always on” GPRS connection.

“Always on”?!! That’s even worse!!

No. Although the terminology is “always on”, cellphone service providers tend to charge for GPRS traffic in one of two ways: 1. per KB of data transferred; or 2. a fixed rate regardless of how much traffic there actually is.

I think I’d better explain a few points before we go on.

GSM cellphone networks use a protocol called GPRS (General Packet Radio Service) for transmission of data. This is used, for instance, for photo messaging or WAP browsing, though it can also be used to make a regular internet connection.

If you use your cellphone’s GPRS service to make an internet connection, your phone service provider is also your internet service provider. You dial a special number that gives you access to their GPRS network, you use their domain name servers, etc.

At this point, I think it’s simplest for me to describe what I did to use my mobile phone as a modem.

Before you can do anything, you will need a means to link your phone to your computer, and a copy of wvdial.

To make the connection, if your phone and PC are suitably equipped, you may be able to use Bluetooth or infrared. But my phone, a lowly Nokia 3220, has neither of these. So I used a third-party’s USB-Serial data cable, which I believe is a copy of Nokia’s DKU-5 cable. Ubuntu identifies it as:

Bus 001 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port

Now, connect your phone to your PC, making sure that the phone is on “stand by” (ie not using its WAP browser or making a call). Then give the command

sudo wvdialconf /etc/wvdial.conf

and you should get output along the lines of this:

t0p@lapt0p:~$ sudo wvdialconf
Usage: wvdialconf <configfile-name>
(create/update a wvdial.conf file automatically)
t0p@lapt0p:~$ sudo wvdialconf /etc/wvdial.conf
Scanning your serial ports for a modem.

Port Scan<*1>: Scanning ttyLTM0 first, /dev/modem is a link to it.
ttyLTM0<*1>: ATQ0 V1 E1 — OK
ttyLTM0<*1>: ATQ0 V1 E1 Z — OK
ttyLTM0<*1>: ATQ0 V1 E1 S0=0 — OK
ttyLTM0<*1>: ATQ0 V1 E1 S0=0 &C1 — OK
ttyLTM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 — OK
ttyLTM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyLTM0<*1>: Modem Identifier: ATI — LT V.92 Data+Fax Modem Version 8.31
ttyLTM0<*1>: Speed 4800: AT — OK
ttyLTM0<*1>: Speed 9600: AT — OK
ttyLTM0<*1>: Speed 19200: AT — OK
ttyLTM0<*1>: Speed 38400: AT — OK
ttyLTM0<*1>: Speed 57600: AT — OK
ttyLTM0<*1>: Speed 115200: AT — OK
ttyLTM0<*1>: Max speed is 115200; that should be safe.
ttyLTM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyS0<*1>: ATQ0 V1 E1 — failed with 2400 baud, next try: 9600 baud
ttyS0<*1>: ATQ0 V1 E1 — failed with 9600 baud, next try: 115200 baud
ttyS0<*1>: ATQ0 V1 E1 — and failed too at 115200, giving up.
Port Scan<*1>: S1 S2 S3 S4 S5 S6 S7 S8
Port Scan<*1>: S9 S10 S11 S12 S13 S14 S15 S16
Port Scan<*1>: S17 S18 S19 S20 S21 S22 S23 S24
Port Scan<*1>: S25 S26 S27 S28 S29 S30 S31 S32
Port Scan<*1>: S33 S34 S35 S36 S37 S38 S39 S40
Port Scan<*1>: S41 S42 S43 S44 S45 S46 S47 S48
Port Scan<*1>: S49 S50 S51 S52 S53
WvModem<*1>: Cannot get information for serial port.
ttyUSB0<*1>: ATQ0 V1 E1 — OK
ttyUSB0<*1>: ATQ0 V1 E1 Z — OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 — OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 — OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 — OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyUSB0<*1>: Modem Identifier: ATI — Nokia
ttyUSB0<*1>: Speed 4800: AT — OK
ttyUSB0<*1>: Speed 9600: AT — OK
ttyUSB0<*1>: Speed 19200: AT — OK
ttyUSB0<*1>: Speed 38400: AT — OK
ttyUSB0<*1>: Speed 57600: AT — OK
ttyUSB0<*1>: Speed 115200: AT — OK
ttyUSB0<*1>: Speed 230400: AT — OK
ttyUSB0<*1>: Speed 460800: AT — ~\uffff
ttyUSB0<*1>: Speed 460800: AT — [06]\uffff
ttyUSB0<*1>: Speed 460800: AT — ~\uffff
ttyUSB0<*1>: Max speed is 230400; that should be safe.
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK

Found a modem on /dev/ttyLTM0, using link /dev/modem in config.
Modem configuration written to /etc/wvdial.conf.
ttyLTM0<Info>: Speed 115200; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0″
ttyUSB0<Info>: Speed 230400; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0″

Looking at this output, we can see wvdial found 2 modems: /dev/ttyLTM0 (also known as /dev/modem) and /dev/ttyUSB0. How do we know which (if either) is the phone? By the line:

ttyUSB0<*1>: Modem Identifier: ATI — Nokia

Wvdial dumps its info to the file /etc/wvdial.conf. If we have a look at that fkile it says:

[Dialer Defaults]
Modem = /dev/modem
Baud = 115200
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ISDN = 0
Modem Type = Analog Modem
; Phone = <Target Phone Number>
; Username = <Your Login Name>
; Password = <Your Password>

Hmm. Not much good to us like that.. We need to edit it. Remember the last 2 lines of all that output from the wvdialconf command? Just kn case your photographic memory’s playing up, here they are again:

ttyLTM0<Info>: Speed 115200; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0″
ttyUSB0<Info>: Speed 230400; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0″

You’ll need to call your cell service provider and get some info from them, such as Username and Password. Then, by amalgamating what you learn from the wvdialconf input and what your friendly cellphone people tell you, you should be able to create an /etc/wvdial.conf file that looks similar to this:

[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 230400
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ISDN = 0
Modem Type = Analog Modem
Phone = *99#
Username = A
Password = B
Stupid Mode = 1

Your completed file is unlikely to be exactly the same as mine. For instance, for my mobile network (Orange UK) Username and Password are blank. But wvdial doesn’t like that, you _must_ put something in there. Also, it will not connect unless you include that line

Stupid Mode = 1

As for that unusual phone number, *99# – that’s what you need to make the GPRS connection. Different mobile networks, especially in other countries, will need different numbers. And another user of Orange UK (using a Sony Ericsson phone) reported having to use *99***4*. All I can suggest is: ask your network what to use. If it doesn’t work, experiment.

So, now you have a completed wvdial.conf file, and your phone is connected to your computer, all that’s left is to try it. Open a console (Ctrl+Alt+F1) and type

sudo wvdial

With any luck, your output will resemble this:

t0p@lapt0p:~$ sudo wvdial
–> WvDial: Internet dialer version 1.54.0
–> Cannot get information for serial port.
–> Initializing modem.
–> Sending: ATZ
–> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
–> Modem initialized.
–> Sending: ATDT*99#
–> Waiting for carrier.
~[7f]}#@!}!} } }2}#}$@#}!}$}%\}”}&} }*} } g}%~
–> Carrier detected. Starting PPP immediately.
–> Starting pppd at Wed Apr 26 23:11:44 2006
–> pid of pppd: 11096
–> Using interface ppp0
–> local IP address
–> remote IP address
–> primary DNS address
–> secondary DNS address

Now, the output stops, and seems to “hang”. But it’s not doing nothing – it’s holding the connection open and waiting for you to use it.

To test it, change to another console (eg Ctrl+Alt+F2) and type

ping -c1

and if the connection’s ok, you should get comething like this:

t0p@lapt0p:~$ ping -c1
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=42 time=781 ms

— ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 781.703/781.703/781.703/0.000 ms

So, now to do something _useful_ with this internet connection – like surfing the web. Swap to the graphical interface (Ctrl+Alt+F7), and launch Firefox (or whatever browser you have). If you’re lucky, it’s already configured for this… just type in the URL, and it takes you there!

Note: it very well be quite slow. But that’s only to be expected. This isn’t broadband, cable, not even 56K dialup. It’s a cellular phone, dammit!

Nevertheless, it’s very useful. You can web-surf, use telnet and ssh. Downloading software probably isn’t a very good idea as it’s so slow. Plus a lot of cell plans charge per KB transferred, so you may need to watch your data usage. Then again, if like me you pay a fixed amount no matter how much data you transfer… go for it!!!

When you’ve finished your session, return to the console where you initiated wvdial (Ctrl+Alt+F1 or whatever) and press Ctrl+C. That will break the connection/hang up.

Well, I can’t think of anything to add. If you want to ask me something – feel free!


5 Responses to “Using a GSM mobile phone as a GPRS modem in Linux”

  1. the Munna Says:

    Hello, I am a very new Ubuntu user.. I need to connect my Nokia 6020 which has an Infrared device. My Laptop also got one. how will i know that i have wvdial?

    Can you help Me … ?

    Just give another comment, thank you advance…

  2. heretogo Says:

    Munna! Sorry i didnt reply sooner! Try the command “man wvdial”. If your distro has wvdial, that command will give you lots of info. Dapper Drake Ubuntu included wvdial, but i don’t know about later versions

  3. sandeep Says:

    it dint showed secondary dns server

  4. edgymania Says:

    Great tutorial, but to complete the picture, what about a tutorial on configuring Linux efax-gtk and using a cellphone modem to send faxes over analogue and ISDN lines?

    Having recently converted from MS WIndows to LInux Ubuntu edgy and all my communications to wireless; sending the occasional fax conventionally by wireless remains a must.Tried using a Motorola A835 cellphone for this purpose but could not get the recalcitrant modem to dialogue.I have read about a program called MInicom to interface the modem and fax software but my limited time and knowledge of Linux OS discourages me from diving in. HELP anyone!

  5. Antoine Says:

    Hey, i followed the whole process and all was going well untill the sudo wvdial command, it automatically disconnect immediately my 3220 starts displaying ‘creating connection’, i used ‘*99#’ as the number and it was clearly saying carrier detected. This is the last lines that i see in my Ubuntu breezy badger

    –> pid of pppd: 11096
    –> Using interface ppp0

    after this its tarts disconnecting. What could be the problem? Help


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: