3rd August 2008

How to connect your Ubuntu system to the internet via a Samsung or Nokia mobile phone

1) Make sure your module is loaded

Hardy Heron includes a kernel module which automatically loads when most modern phones supporting internet access are connected via USB. You can check this by connecting your phone then running the command:

dmesg | grep cdc_acm
You should see a line like:
[104.132131] cdc_acm 1-2:2.1: ttyACM0: USB ACM device

If you see such a line, then you are most of the way there! Your Ubuntu system has loaded a driver and created a device node called /dev/ttyACM0 which appears as a serial modem! The PPP scripts below are configured to talk to your phone via /dev/ttyACM0.

If you don't see such a line, perhaps:

  1. Your phone is set to mass storage profile, not modem profile. Consult your handbook or rummage through the menus
  2. Your USB cable is faulty, or another problem with your USB socket. Try plugging a USB flash drive in
  3. Your phone doesn‘t support computer connections for data. Perhaps your phone provider have customised the firmware and eliminated the functionality?
  4. Your phone uses a different driver, or an unsupported driver

2) Setting up pppd

pppd is point-to-point-daemon. For our purposes, it is a program which we‘ll run to create a virtual network adapter linked to a virtual modem at the end of a virtual serial line. The virtual serial port is the one emulated by the phone over USB (/dev/ttyACM0). The virtual network adapter can be seen on the machine as ppp0 when pppd is running. (USB is serial, but the phone offers emulation of an RS-232 style serial port over USB so the serial port we are interested in is really virtual and looks, for most purposes, like a com port).

All this virtual serial over USB probably looks rather anachronistic to you. I reckon it is. However, it does provide a good degree of compatibility with existing networking systems and drivers, so don‘t knock it!

Setting up pppd with the included files is fairly straightforward. The files I have included are pre-configured for the UK O2 Telefonica network. You will need to make minor edits the files for your own network provider. More of that later.

pppd scripts for Samsung and Nokia

The scripts for the Samsung and Nokia are the same except for the gprs-connect-chat. I have removed an ATH command sequence for the Samsung. The ATH initialisation gives NO CARRIER on the Tocco F480. Removing the sequence makes the script work for the F480 and has had no negative effects on the phones I have tried so far.
I have not (yet) tried the script without the ATH command sequence with an E65. The Samsung sequence may well work with a Symbian Nokia.

Copy the Samsung or Nokia scripts to /etc/pppd/peers. So they should end up as:

/etc/ppp/peers/gprs
/etc/ppp/peers/gprs-connect-chat
/etc/ppp/peers/gprs-disconnect-chat
Make sure the gprs-connect-chat and gprs-disconnect-chat scripts are executable:
chmod 755 /etc/ppp/peers/gprs-connect-chat /etc/ppp/peers/gprs-disconnect-chat
Edit the line in gprs-connect-chat:
	OK		'AT+CGDCONT =1,"IP","mobile.o2.co.uk","",0,0'	\
With the appropriate service provider APM address. Here is a list of UK service provider APM addresses and other info.

You should now be ready to connect. Run:

pppd call gprs
...To bring up your internet connection via your mobile phone. Assuming that works, move to the next stage to create a desktop icon which you can double-click to connect. If this doesn‘t work, check your ppp scripts are executable and check the dialling strings are suitable for your network. pppd provides plenty of output to help diagnose any problem.

3) Make a friendly front-end with a double-click

We‘ll create a start-up script which launches an xterm to see the pppd output, and give us a way to shut down pppd by using ctrl+c in the terminal window. We'll then set the script to run as root without requiring a password.

Put the following into a file /etc/ppp/connect_gprs then make owned as root:root, chmod 755.

#!/bin/bash
xterm -e pppd call gprs
Add the following to the very bottom of the /etc/sudoers file:
%dialout ALL=NOPASSWD: /etc/ppp/connect_gprs
Check this works by running, as a user who is also a member of the dialout:
/etc/ppp/connect_gprs
This should bring up an xterm terminal, and connect you to the internet via your mobile phone. Finish off by making a desktop icon:

Right click on desktop. Select create launcher... Enter /etc/ppp/connect_gprs as the command.

Assuming you are a member of dialout group, you should now be able to launch an internet connection via your mobile phone by simply double-clicking your desktop icon. Click in the terminal window then hit ctrl+c to disconnect.

To minimise possibility of machine compromise, you may want to make sure nobody other than root can modify the PPP scripts. The scripts run as root, so creating scripts with non-root ownership opens up possibility of exploit. You could run the following to make sure;

chown root:root /etc/ppp/peers/gprs /etc/ppp/peers/gprs-connect-chat /etc/ppp/peers/gprs-disconnect-chat /etc/ppp/connect_gprs
chmod 755 /etc/ppp/peers/gprs-connect-chat /etc/ppp/peers/gprs-disconnect-chat /etc/ppp/connect_gprs
chmod 644 /etc/ppp/peers/gprs



Thanks to davesource.com for the hints and the scripts, and of course to http://kapsi.fi/~mcfrisk/linux_gprs.html for the original scripts.

Technical support is available on premium rate telephone 0911 750 3579. Calls charged at £1/minute.

You can help sponsor more help pages by taking a look at some of the following offers and buying something, For example;

use-anywhere wireless broadband. You can use it at home, on the train, in the car. No telephone line required. 3Gb, no broadband router or additional wireless card required, all equipment included for £15/month!

...Or take a look at one of their competitive mobile phone packages Orange will give you a touch phone much like the apple Iphone on a contract- the Toca F480. I have used one and they are good, and as you know, can be used for mobile broadband too! Get a package to include mobile broadband with your Mobile phone package. The Toco F480 also makes a good mobile video player, music player and can surf the web from it‘s touch screen..

...Or click for an Orange pay-as-you-go SIM card for £1 with no monthly fee, 300 free texts and 120 off-peak free any-network minutes as a bonus for a £10 top-up in addition to the credit you bought on Canary.

O2 also provide good Mobile and Broadband and phone combined packages. An O2 monthly tarriff has a free bolt-on option. Choose an "unlimited web" bolt on, I understand this gives up to 1Gb transfer a month.
Although O2 have less 3G coverage than other providers, they are upgrading the network to EDGE. EDGE is an evolution of GSM. Given that the GSM networks tend to have a better coverage and 900Mhz appears to have better penetration of buildings than 2.1Ghz 3G, this approach may provide a more dependable fast broadband, if availability in awkward spots is more important than raw maximum speed.

Or take a look at Three Mobile's internet packages. As of Aug 08, you can get 1Gb £10/month, 5Gb £15/month or for heavy users, 15Gb for £30/month including USB modems.

Another good package is T-Mobile's combo internet and phone package £30/month 700 mins, unl texts, FREE WEBnWalk internet, Free phone. Three and T-Mobile have entered into a sharing arrangement for 3G masts, so T-Mobile's 3G service should cover as widely as Three‘s soon.



<<Back to Nick‘s home page