Linux Tutorial: How to use a cellphone as a modem

avatar666.pngavatar666.pngavatar666.pngavatar666.png

Note: There is more up-to-date info on this subject, especially concerning mobile broadband HSDPA modems and 3G cellphones, to be found here. But the info on this page is still relevant. In particular, this page covers the program wvdial, which can be used if your network manager doesn’t detect your HSDPA modem.

I learnt how to connect to the internet through my cellphone because it was the only way I could get online from my home – at the time I was living in a flat where I wasn’t permitted to have a regular phoneline installed. And I still sometimes find it useful: if I’m out and about with my laptop, and I can’t find a wifi “hotspot” to use, I can generally get a GSM signal – in the UK it’s possible to get a signal in just about every urban area, and in a lot of rural areas too – and a GSM signal means you can connect to the internet via GPRS.

Some mobile service plans charge for internet access on a per MB of transferred data basis. This can turn out very expensive, as there is a lot of data transferred during an internet session. Especially if you download a 3 GB movie DVD!! However, many mobile plans charge a set fee for unlimited net access. My mobile provider, Orange, charge me £1 for one day’s unlimited access or £5 for a week’s access. And I believe in the USA it’s much cheaper.

So how do you use a mobile phone as a modem? With Windows, I haven’t got a clue. But with Linux, you establish a PPP connection with the mobile service provider’s servers, by using a dialler like wvdial. Wvdial comes included with a default installation of Ubuntu (my particular distro) and probably other Linux flavours too.

Connect your phone to the computer. I do this with a USB datacable that came with the phone, but some people use Bluetooth. The phone should be ON. My phone is a Sony Ericsson – when it’s linked to the computer, I have to choose between File Transfer and Phone Mode. To use the phone as a modem, I have to select Phone Mode. However, I sometimes use a Nokia phone, and there’s no mode-choosing necessary with that model.

Open a terminal and get yourself root status. Then type in the command

wvdialconf

This will cause wvdial to scan the computer for modems. You’ll get output something like this:

root@x-box:~# wvdialconf

Scanning your serial ports for a modem.

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.
Modem Port Scan<*1>: S1 S2 S3
WvModem<*1>: Cannot get information for serial port.
ttyACM0<*1>: ATQ0 V1 E1 — OK
ttyACM0<*1>: ATQ0 V1 E1 Z — OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 — OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 — OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 — OK
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyACM0<*1>: Modem Identifier: ATI — Sony Ericsson W300
ttyACM0<*1>: Speed 4800: AT — OK
ttyACM0<*1>: Speed 9600: AT — OK
ttyACM0<*1>: Speed 19200: AT — OK
ttyACM0<*1>: Speed 38400: AT — OK
ttyACM0<*1>: Speed 57600: AT — OK
ttyACM0<*1>: Speed 115200: AT — OK
ttyACM0<*1>: Speed 230400: AT — OK
ttyACM0<*1>: Speed 460800: AT — OK
ttyACM0<*1>: Max speed is 460800; that should be safe.
ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK

Found an USB modem on /dev/ttyACM0.
/etc/wvdial.conf<Warn>: Can’t open ‘/etc/wvdial.conf’ for reading: No such file or directory
/etc/wvdial.conf<Warn>: …starting with blank configuration.
Modem configuration written to /etc/wvdial.conf.
ttyACM0<Info>: Speed 460800; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0”
ttyACM1<Info>: Speed 460800; init “ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0”
root@x-box:~#

[Note: I’ve edited the output, to cut down on its length.]

Wvdial found my cellphone (“Modem Identifier: ATI — Sony Ericsson W300”), and reports that the phone is on port ttyACM0.

Then wvdial created a configuration file (/etc/wvdial.conf) and put some config info about the phone in it.

Edit /etc/wvdial.conf with your mobile service provider’s information. When I ran wvdialconf, the program created a wvdial.conf file as below:

root@x-box:~# cat /etc/wvdial.conf

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

The program filled in some fields, but some have been left for you to do: specifically, the info needed to log in to your mobile service provider’s web servers. I edited the file to look like this:

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

The number in the Phone field is the number that the phone needs to call to access my mobile provider’s GPRS service. Your mobile network may use a different number – you’ll have to ask them.

My mobile network does not require usernames and passwords to access the web servers. But wvdial doesn’t like empty fields. So I put “A” and “B” in them.

I added the last line: Stupid Mode = Yes, otherwise wvdial will simply cycle when run without ever connecting.

*IMPORTANT* All the output recreated above is from a system that did not have any other modems connected. Most laptops have a modem or network card built-in, which wvdialconf will detect. But you’ll be able to see what information relates to your phone, and edit your wvdial.conf file accordingly.

So, now you can connect to the internet. To do this, open that terminal and, as root, type in the command

wvdial

You’ll get output like this:

root@x-box:~# wvdial
WvDial<*1>: WvDial: Internet dialer version 1.56
WvModem<*1>: Cannot get information for serial port.
WvDial<*1>: Initializing modem.
WvDial<*1>: Sending: ATZ
WvDial Modem<*1>: ATZ
WvDial Modem<*1>: OK
WvDial<*1>: Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
WvDial Modem<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
WvDial Modem<*1>: OK
WvDial<*1>: Modem initialized.
WvDial<*1>: Sending: ATDT*99#
WvDial<*1>: Waiting for carrier.
WvDial Modem<*1>: ATDT*99#
WvDial Modem<*1>: CONNECT
WvDial Modem<*1>: ~[7f]}#@!}!}!} }8}#}$@#}(}”}’}”}”}&} } } } }%}&}$AUSgn~
WvDial<*1>: Carrier detected. Starting PPP immediately.
WvDial<Notice>: Starting pppd at Wed Jan 16 15:45:03 2008
WvDial<Notice>: Pid of pppd: 10689
WvDial<*1>: Using interface ppp0
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: local IP address 172.23.108.122
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: remote IP address 194.33.25.101
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: primary DNS address 193.36.81.37
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: secondary DNS address 193.36.81.38
WvDial<*1>: pppd: ��[06][08]��[06][08]

The program will appear to “hang” – the above text will just freeze on the monitor. But wvdial is actually holding the connection open until you terminate the link by hitting Ctrl-C.

Now you can use the connection by, for example, starting up your web browser; or open another terminal and run telnet or ssh, or do whois or ping commands. All these activities will run a lot slower than you’re used to – but they will run.

When you’re finished, hit Ctrl-C and wvdial will end with a closing message like this:

Caught signal 2: Attempting to exit gracefully…
WvDial<*1>: Terminating on signal 15
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: Connect time 0.8 minutes.
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: pppd: ��[06][08]��[06][08]
WvDial<*1>: Disconnecting at Wed Jan 16 15:45:50 2008
root@x-box:~#

Data connections via GPRS over GSM are very slow – mine often average about 5 K/sec. But 3G/UMTS is much faster. Nowhere near the performance over a landline, of course, but 3G will probably be the best bet. However, be warned: some mobile providers don’t like their customers to link to the internet this way, and I’ve been told that 3, a UK company, actively prevent it. Their customers can pay extra to get a GPRS modem, but linking a normal cellphone on a standard plan is not permitted. Tmobile also don’t like their customers to use their phones as modems. So beware! Or, better yet, use a network that doesn’t have such stupid rules!!

_gos=’c4.gostats.com’;_goa=354450;
_got=2;_goi=2;_goz=0;_gol=’Free hit counter’;_GoStatsRun();
Free hit counter
Free hit counter

32 Responses to Linux Tutorial: How to use a cellphone as a modem

  1. nickjk94 says:

    Damn, that’s good stuff. I seldom use Linux, but that’s handy to know. Though I’m sure the price on my cell phone plan would end up being rather unfortunate.

    Cheers on an interesting blog…

  2. junbert says:

    Interesting link..
    thanks!

    junbert@
    http://www.cypherbox.net

  3. gresh says:

    great howto, this helped me a lot
    many thanks!!!

  4. Juan Jacques says:

    thanks for this tutorial… i have just recently use my brothers cellphone to connect to the internet using windows. with this tutorial i’m goin to try running it on my linux box. thanks again

  5. Piusor says:

    Brilliant post.., guy

  6. Kyle says:

    This is great info.

    I have a 3G datacard (PCMCIA) which I installed in my PC (through a ENE PCI to PCMCIA converter). I battled to get Linux to see the 3G modem until I installed the right applications from BetaVine. This is a dedicated Vodafone project for open source software for the Vodafone network (globally).

    I installed the software on my UBUNTU UE 8.04 and I haven’t looked back.

    http://www.betavine.net

  7. Kyle says:

    In addition, I get download speeds in excess of 800kbps – top speed of 1.2Mbps, depending on signal strength.

  8. mlandvod12 says:

    Thumbs up with ur blog man.

  9. Chuck says:

    I have tried the HOWTO and I can tell it connects, but I am unable to browse or get mail thru Evolution. I can ping from a terminal, ifconfig shows ppd0 connection is up, but I just cannot get anywhere. I am using Ubuntu 8.04.01 and would appreciate any help u can provide.

  10. Farid says:

    I can only appreciate your courage!!! , you are courageous, it is very well.

  11. Jhun says:

    Sir is these also will work for a cdma? Nice blog! thanks for the info, you’re the man!

  12. adexer says:

    i like what you did here

  13. adexer says:

    is anybody here to help

    • t0p says:

      I don’t check these comments as often as I should. But I’m happy to help you if I can. If you want to get speedier replies, you might be better contacting me through the contact form.

  14. dinesh says:

    i want to connect my bsnl broad band on fedora core 6.please guide me.

  15. […] Broadband on Linux Note: There’s more info on this subject here. So take a look if this post doesn’t do it for […]

  16. Nice level of information here. There is so much data around about this subject that sometimes you cannot see the wood for the trees but you have pitched this at just the right level so that the lay person can understand – thank you!

  17. […] wvdial in Ubuntu! If you are an Ubuntero and use dial-up to connect to the internet or use a cellphone as a modem, you may have noticed that the “intelligent dialer” utility wvdial is no longer […]

  18. DVD burner says:

    It is good idea. I support you.

  19. Emmanuel says:

    Awesome!!!!!

  20. […] get 3G working. Here is a post where guys made it work on Linux (Ubuntu has Wvdial by default): Linux Tutorial: How to use a cellphone as a modem Connecting our mobile phone to Android tablet also has the potential of reading/writing SMS on […]

  21. Nice level of information here. There is so much data around about this subject that sometimes you cannot see the wood for the trees but you have pitched this at just the right level so that the lay person can understand – thank you!

  22. […] Linux Tutorial: How to use a cellphone as a modem February 200822 comments […]

  23. pdq terminal tip…

    […]Linux Tutorial: How to use a cellphone as a modem « I HATE HATE!!![…]…

  24. low cost payment processing…

    […]Linux Tutorial: How to use a cellphone as a modem « I HATE HATE!!![…]…

  25. Linux Howtos says:

    Linux Howtos…

    […]Linux Tutorial: How to use a cellphone as a modem « I HATE HATE!!![…]…

  26. Purusothaman A says:

    Hi,

    I have been looking for wvdial for my android honeycomb tablet for using my Sony
    Ericsson Hazel (j20i) mobile (non-andoird) as modem.

    ie, I have non-android mobile with GPRS enabled.
    I like to connect this to my honeycomb tablet then use my mobile as modem.

    But sadly, honeycomb does not have wvdial.

    Any thoughts ?

  27. Ceci est un website ideal pour rattraper son retard sur la plupart des films classiques jamais fait.
    Mais il ya beaucoup de sites qui offrent des movie streaming vf sur et sont
    legitimes. Filmoviez – Un site qui gagne en popularite tous les semaines.

  28. Marvelous, what a webpage it is! This weblog provides valuable data to us,
    keep it up.

  29. finanzierung says:

    My spouse and I absolutely love your blog and find the majority of your post’s to be just what I’m looking for.
    Does one offer guest writers to write content available for you?
    I wouldn’t mind publishing a post or elaborating on many of the
    subjects you write regarding here. Again, awesome web site!

  30. I read this post completely regarding the resemblance of most recent and previous technologies, it’s amazing article.

  31. linux guide says:

    I think that is one of the so much important info for me.
    And i am satisfied reading your article. However should
    statement on some common issues, The site style is great, the articles is
    in point of fact excellent : D. Just right job,
    cheers

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: