Mobile internet using you mobile phone in Linux

When I am on the road sometimes its very handy to have internet around.

luckily this is very easy to accomplish in Linux. In this case I will be using a Samsung F700 Mobile phone connected to my Asus EEE 701 laptop running Ubuntu linux.

A few things however to think of before you start:
– Do you have a ‘unlimited’ or limited (100MiB/1GiB etc..) contract (‘unlimited’ is recommended)
– Does your provider allow dial up using your phone & laptop (By Vodafone it is not allowed but if you use it for ‘normal’ web browsing they don’t mind (if you start using it to download your latest TV episode’s or whatever you will be shutdown.)

So lets start:

First connect the phone to the laptop using the USB cable in my case the phone will ask me in what ‘mode’ the phone should operate, I need to select ‘pc studio’ to use the phone as a gateway to the internet.

Now when the phone is connected to the PC open a terminal and run wvdialconf to create a new config file:

trouble@sun:$ sudo wvdialconf /etc/wvdial.conf

Editing `/etc/wvdial.conf’.

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 — ERROR
ttyACM0<*1>: Modem Identifier: ATI — Manufacturer: SAMSUNG ELECTRONICS CORPORATION
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 — OK

Found an USB modem on /dev/ttyACM0.
Modem configuration written to /etc/wvdial.conf.
ttyACM0: Speed 460800; init “ATQ0 V1 E1 S0=0 &C1 &D2”

As you can see it found my Samsung F700 phone and updated the wvdial.conf file.

Now we need to edit the wvdial.conf file to add a few paramaters (user/pass & dial number)
the default config file looks like this:

trouble@sun:$ $ cat /etc/wvdial.conf

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
Modem Type = USB Modem
Baud = 460800
New PPPD = yes
Modem = /dev/ttyACM0
ISDN = 0
; Phone =
; Password =
; Username =

Now you will need to know the ‘Target Phone Number’ for vodafone in the Netherlands this is ‘*99#’ but this might be different in your case so just ‘google’ around if you have a other provider for the target phone number.

The username and password can be just random but I like to keep it simple and changed both to ‘vodafone’

Also you need to enable ‘stupid mode’ in wvdial to work around some of the ‘intelligence’ in wvdial to get it to work.

So vi the wvdial.conf file and it should look like this:

trouble@sun:$ $ sudo vi /etc/wvdial.conf
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
Modem Type = USB Modem
Baud = 460800
New PPPD = yes
Modem = /dev/ttyACM0
ISDN = 0
Phone = *99#
Password = vodafone
Username = vodafone
Stupid Mode = 1

Now you are ready to go, so start ‘wvdial’ and you should be connected (I created a desktop terminal launcher with the command: ‘sudo wvdial’ for this).

trouble@sun:$ $ sudo wvdial
–> WvDial: Internet dialer version 1.60
–> Cannot get information for serial port.
–> Initializing modem.
–> Sending: ATZ
ATZ
OK
–> Sending: ATQ0 V1 E1 S0=0 &C1 &D2
ATQ0 V1 E1 S0=0 &C1 &D2
OK
–> Modem initialized.
–> Sending: ATDT*99#
–> Waiting for carrier.
ATDT*99#
CONNECT
–> Carrier detected. Starting PPP immediately.
–> Starting pppd at Sun Aug 24 18:14:11 2008
–> Pid of pppd: 23198
–> Using interface ppp0
–> pppd: ��[06][08]��[06][08]
–> pppd: ��[06][08]��[06][08]
–> pppd: ��[06][08]��[06][08]
–> pppd: ��[06][08]��[06][08]
–> pppd: ��[06][08]��[06][08]
–> pppd: ��[06][08]��[06][08]
–> pppd: ��[06][08]��[06][08]
–> local IP address YOURIP
–> pppd: ��[06][08]��[06][08]
–> remote IP address GATEWAYIP
–> pppd: ��[06][08]��[06][08]
–> primary DNS address DNSIP
–> pppd: ��[06][08]��[06][08]
–> secondary DNS address DNSIP
–> pppd: ��[06][08]��[06][08]
0

Setting up a UMTS connection using a KPN mobile connect card

Preparing

First you will need to see which serial port is used by your UMTS card.
So plugin your KPN Mobile connect card and start up the PCMCIA service.

# /etc/init.d/pcmcia start

Then you will see something like this in your dmesg output:

ttyS1 at I/O 0x2f8 (irq = 19) is a 16550A

So ttyS1 is our serial port.

Config files

Make sure to change the ttyS# in the config files.
vi /usr/bin/umtsinit

#!/bin/sh
DEFAULTPIN="0000";
TTYDEV="/dev/ttyS1";
if [ $1 ] ; then
PIN=$1;
else
PIN=$DEFAULTPIN;
fi
echo "at" > $TTYDEV;
sleep 1;
echo "at+cpin=\"$PIN\"" > $TTYDEV;
echo "PIN send to $TTYDEV";

vi /etc/ppp/peers/umts

/dev/ttyS1 460800
connect '/usr/sbin/chat -v -f /etc/ppp/chat-umts'
novj
crtscts
noauth
defaultroute
debug
nodeflate
noccp
noipdefault
noaccomp
usepeerdns

vi /etc/ppp/chat-umts

TIMEOUT 5
ECHO ON
ABORT 'nBUSYr'
ABORT 'nERRORr'
ABORT 'nNO ANSWERr'
ABORT 'nNO CARRIERr'
ABORT 'nNO DIALTONEr'
ABORT 'nRINGINGrnrnRINGINGr'
'' rAT
TIMEOUT 12
OK ATZ
OK 'AT+cgdcont=1,"IP","internet",,0,0'
OK ATD*99***1#

Start/Stop Script

vi /etc/init.d/umts

#!/bin/sh

case "$1" in
  start)
        echo "Starting up UMTS"
        echo "Checking for files"
        if [ -f /etc/ppp/chat-umts ] ; then
          echo "/etc/ppp/chat-umts                      [OK]"
         else
          echo "ERROR: The file /etc/ppp/chat-umts does not exist."
        fi

        if [ -f /etc/ppp/peers/umts ] ; then
          echo "/etc/ppp/peers/umts                     [OK]"
         else
          echo "ERROR: The file /etc/ppp/chat-umts does not exist."
        fi

        if [ -f /usr/bin/umtsinit ] ; then
          echo "/usr/bin/umtsinit                       [OK]"
         else
          echo "ERROR: The file /etc/ppp/chat-umts does not exist."
        fi
        echo "Shuting down network interfaces"
        ifdown eth0
        ifdown eth1

        /usr/bin/umtsinit
        sleep 10
        /usr/sbin/pppd call umts
        ;;
  stop)
        /usr/bin/poff
        ;;
  *)
        N=/etc/init.d/umts
        echo "Usage: $N start/stop" >&2
        exit 1
        ;;
esac

exit 0

Related Sites

http://www.xs4all.nl/helpdesk/mobielinternet/umts/linux/

0