This page describes how to use a cell phone and a USB cable to connect your pc to the internet. For this example I used:
- Ubuntu Breezy
- a Nokia 6021 cell phone
- a CA-42 cable
- an Italian Vodafone provider
The instructions should be valid with minimal modifications also for a Bluetooth or infrared connection and for other providers.
I used the packages wvdial and netenv, which can be installed by
sudo apt-get install wvdial sudo apt-get install netenv
1. Configuring the cell phone
The cell phone is configured by chosing
Menù -> Impostazioni -> Connettività -> GPRS -> Impostazioni modem gprs
- "Punto di accesso attivo": VO GPRS
- "Punto di accesso gprs": web.omnitel.it
(may be this is is not really necessary, but it was suggested by the Vodafone customer care and I have not tried without it).
2. Connecting the cell phone to the pc
The cell phone is connected to the pc by the cable and a USB port. Observing the file /var/log/syslog we see that a file /dev/ttyACM0 is created. It will be used to communicate with the cell phone:
$ tail -F /var/log/syslog Apr 15 12:00:28 localhost kernel: [4299673.731000] usb 3-1: new full speed USB device using uhci_hcd and address 2 Apr 15 12:00:29 localhost kernel: [4299674.411000] drivers/usb/class/cdc-acm.c: This device cannot do calls on its own. It is no modem. Apr 15 12:00:29 localhost kernel: [4299674.411000] cdc_acm 3-1:1.0: ttyACM0: USB ACM device Apr 15 12:00:29 localhost kernel: [4299674.415000] usbcore: registered new drive r cdc_acm Apr 15 12:00:29 localhost kernel: [4299674.415000] drivers/usb/class/cdc-acm.c: v0.23:USB Abstract Control Model driver for USB modems and ISDN adapters Apr 15 12:00:29 localhost usb.agent: cdc-acm: loaded successfully
3. Finding the modem parameters
Using the command wvdialconf the cell phone modem is recognized and the relevant parameters are written in /etc/wvdial.conf:
$ sudo wvdialconf /etc/wvdial.conf Password: Scanning your serial ports for a modem. Port Scan<*1>: S0 S1 S2 S3 S4 S5 S6 S7 Port Scan<*1>: S8 S9 S10 S11 S12 S13 S14 S15 Port Scan<*1>: S16 S17 S18 S19 S20 S21 S22 S23 Port Scan<*1>: S24 S25 S26 S27 S28 S29 S30 S31 Port Scan<*1>: S32 S33 S34 S35 S36 S37 S38 S39 Port Scan<*1>: S40 S41 S42 S43 S44 S45 S46 S47 Port Scan<*1>: S48 S49 S50 S51 S52 S53 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 -- Nokia 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 -- ttyACM0<*1>: Speed 460800: AT -- ttyACM0<*1>: Speed 460800: AT -- ttyACM0<*1>: Max speed is 230400; that should be safe. ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK Found an USB modem on /dev/ttyACM0. Modem configuration written to /etc/wvdial.conf. ttyACM0<Info>: Speed 230400; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
4. Modifying the configuration file
The file /etc/wvdial.conf has to be manually modified to add the row with the initialization string Init3, the Vodafone phone number (*99#) and the empty string for Username and Password:
$ sudo cat /etc/wvdial.conf [Dialer Defaults] Modem = /dev/ttyACM0 Baud = 230400 Init1 = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init3 = AT+CGDCONT=1,"IP","web.omnitel.it" ISDN = 0 Modem Type = USB Modem Phone = *99# Username = ''
5. Modifying /etc/network/interfaces
The files /etc/network/interfaces and /etc/resolv.conf should be modified as follows:
$ cat /etc/network/interfaces # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto ppp0 iface ppp0 inet wvdial
$ cat /etc/resolv.conf nameserver 184.108.40.206 nameserver 220.127.116.11
(modifying /etc/resolv.conf is probably unnecessary but I have not tried without it)
Connect using the command wvdial. The correct establishment of the connection can be verified by observing the file /var/log/syslog. At the moment of the connection the Nokia 6021 screen shows that a GPRS connection is being established. All recent Vodafone cell phone cards in Italy have GPRS modem connection enabled by default, just call the number 190 to know the cost.
$ sudo wvdial --> WvDial: Internet dialer version 1.54.0 --> Cannot get information for serial port. --> Initializing modem. --> Sending: ATZ ATZ OK --> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 OK --> Sending: AT+CGDCONT=1,"IP","web.omnitel.it" AT+CGDCONT=1,"IP","web.omnitel.it" OK --> Modem initialized. --> Sending: ATDT*99# --> Waiting for carrier. ATDT*99# CONNECT ~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~ --> Carrier detected. Waiting for prompt. ~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~ --> PPP negotiation detected. --> Starting pppd at Sat Apr 15 12:02:02 2006 --> pid of pppd: 18018 --> Using interface ppp0 --> local IP address 18.104.22.168 --> remote IP address 10.6.6.6 --> primary DNS address 22.214.171.124 --> secondary DNS address 126.96.36.199
$ tail -F /var/log/syslog Apr 15 12:02:02 localhost kernel: [4299768.004000] CSLIP: code copyright 1989 Regents of the University of California Apr 15 12:02:02 localhost kernel: [4299768.017000] PPP generic driver version 2. 4.2 Apr 15 12:02:02 localhost pppd: pppd 2.4.3 started by root, uid 0 Apr 15 12:02:02 localhost pppd: Using interface ppp0 Apr 15 12:02:02 localhost pppd: Connect: ppp0 <--> /dev/ttyACM0 Apr 15 12:02:08 localhost pppd: PAP authentication succeeded Apr 15 12:02:08 localhost kernel: [4299773.958000] PPP BSD Compression module registered Apr 15 12:02:08 localhost kernel: [4299774.038000] PPP Deflate Compression module registered Apr 15 12:02:10 localhost pppd: Cannot determine ethernet address for proxy ARP Apr 15 12:02:10 localhost pppd: local IP address 188.8.131.52 Apr 15 12:02:10 localhost pppd: remote IP address 10.6.6.6 Apr 15 12:02:10 localhost pppd: primary DNS address 184.108.40.206 Apr 15 12:02:10 localhost pppd: secondary DNS address 220.127.116.11
7. Interrupting the connection
The connection can be interrupted by a Ctrl-C. The result is shown in /var/log/syslog:
Caught signal #2! Attempting to exit gracefully... --> Terminating on signal 15 --> Connect time 0.3 minutes. --> Disconnecting at Sat Apr 15 12:02:28 2006
$ tail -F /var/log/syslog Apr 15 12:02:27 localhost pppd: Terminating on signal 15 Apr 15 12:02:27 localhost pppd: Connect time 0.3 minutes. Apr 15 12:02:27 localhost pppd: Sent 0 bytes, received 0 bytes. Apr 15 12:02:27 localhost pppd: Connection terminated.
8. Connecting using /etc/init.d/networking
The connection can be established and interrupted also by the following commands (if point 5 has been followed):
$ sudo /etc/init.d/networking start * Configuring network interfaces... [ ok ] $ sudo /etc/init.d/networking stop * Deconfiguring network interfaces... [ ok ]
9. Connecting using netenv
The netenv package can be used to select different laptop network configurations. Just copy /etc/network/interfaces and /etc/resolv.conf to /etc/netenv/interfaces.netenv-ppp and /etc/netenv/resolv.conf.netenv-ppp, and create /etc/netenv/setup-ppp, /etc/netenv/<localhost>-ppp in such a way that the ppp connection can be established by the command sudo netenv. Substitute <localhost> with the name of the machine you are using. (The following example is Debian specific, see netenv documentation).
$ cat setup-ppp #!/bin/sh if [ -r /etc/netenv/interfaces.netenv-ppp ]; then mv /etc/network/interfaces /etc/network/interfaces.netenv-old ln -s /etc/netenv/interfaces.netenv-ppp /etc/network/interfaces fi if [ -r /etc/netenv/resolv.conf.netenv-ppp ]; then mv /etc/resolv.conf /etc/resolv.conf.netenv-old ln -s /etc/netenv/resolv.conf.netenv-ppp /etc/resolv.conf fi
$ cat <localhost>-ppp netenv_id=ppp
Nokia 5500 Sport in Dapper Drake with USB
Getting it up and running was quite easy:
- plug in your phone with the USB cable
- select "PC Suite Mode" from you phone
- the phone is autodetected
- run the following commands:
# sudo apt-get install wvdial # sudo wvdial # sudo nano /etc/wvdial.conf
Note lines with
Init3 = AT+CGDCONT=1,"IP","internet"
- Phone = *99#
The name of the connection may vary according to your GPRS provider. I use DNA Finland. For Elisa in Finland the username should be 'rl'.
[Dialer Defaults] Init1 = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init3 = AT+CGDCONT=1,"IP","internet" Modem Type = USB Modem #Baud = 460800 Baud = 230400 New PPPD = yes Modem = /dev/ttyACM0 ISDN = 0 Phone = *99# Username = '' Password = '' # sudo nano /etc/network/interfaces auto ppp0 iface ppp0 inet wvdial # sudo /etc/init.d/networking restart
Check that your connection works with ping www.ubuntu.fi