USB 3G Modem

From ArchWiki
Revision as of 08:00, 22 July 2010 by Aedit (Talk | contribs)

Jump to: navigation, search


A number of mobile telephone networks around the world offer mobile internet connections over UMTS (or EDGE or GSM) using a portable USB modem device.

Device identification

Install usbutils

pacman -S usbutils

and then examine the output of

$ lsusb

which will show the vendor and product IDs of the device. Note that some devices will show two different product IDs at different times as explained below.

Mode switching

Often these devices will have two modes (1) USB flash memory storage (2) USB Modem. The first mode, sometimes known as ZeroCD, is often used to deliver an internet communications program for another operating system and is generally of no interest to Linux users. Additionally some have a slot into which the user can insert an additional flash memory card.

A useful utility for switching these devices into modem mode is usb_modeswitch, available in [community]:

pacman -S usb_modeswitch

Udev rules are supplied with the package in Template:Filename. This contains entries for many devices, which it will switch to modem mode upon insertion.

When a device is switched, its product ID may change to a different value. The vendor ID will remain unchanged. This can be seen in the output of lsusb.

Some devices are supported in the USB serial kernel module called "option" (after the Option devices, but not limited to just those) and may be used without usb_modeswitch.

Udev itself included a utility called Template:Filename. In udev 157 this was renamed to Template:Filename and morphed into a tool that only switches Mobile Action cables. For other devices use usb_modeswitch.

Connection

The general procedure is to switch the device into modem mode, make sure the ttyUSB device(s) are recognized by the usbserial kernel module, and then to run wvdial to dial, connect and start pppd.

Install wvdial

pacman -S wvdial

The configuration file /etc/wvdial.conf will in general depend on (a) which device you have (b) which mobile network you are connecting to. A single wvdial.conf file can be defined with named sections to be usable with several USB modems and networks, should you need them.

Run (as root)

# wvdialconf

which will attempt to write /etc/wvdial.conf correctly. You will need to add the user, password and Access Point Name (APN). You can obtain these (i) from your network provider, (ii) from other users via published wvdial.confs, or (iii) by logging the USB tty traffic under another operating system (Sysinternals' Portmon).

A typical /etc/wvdial.conf looks like this:

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
ISDN = 0
Modem = /dev/ttyUSB2
Baud = 9600

[Dialer thenet]
Phone = *99***1#
Username = thenetuser
Password = thenetpw
Stupid Mode = 1
Baud = 460800
Init3 = AT+CGDCONT=1,"IP","apn.thenet.net"

[Dialer mypin]
Init4 = AT+CPIN=1234

Often there will be several devices (at /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2 for example). If in doubt about which to use, try each of them in turn or use /dev/gsmmodem (a link set up by usb_modeswitch) which should point to the correct one. Once the configuration files are prepared, the internet connection is established by running

$ wvdial <section>

If necessary additional setup commands can be placed simple script like this:

usbmodeswitch
sleep 2
modprobe usbserial vendor=0xVVVV product=0xMMMM maxSize=4096
sleep 2
wvdial thenet

where VVVV is the hexadecimal vendor ID from lsusb, and MMMM is the hexadecimal product ID when in modem mode, and "thenet" is the name of the section in wvdial.conf which you wish to use. The maxSize option may or may not be necessary. It simplifies matters if you disable the SIM PIN, but if you require it, run "wvdial mypin" before "wvdial thenet".

The final wvdial command should start pppd and the obained IP address should be visible in the terminal output. At that point the internet connection should be live, which can be easily checked with a web browser or by pinging an external IP address.

Related Articles

Huawei E220
Allow users to dial with wvdial
Idea_netsetter(Huawei_EG162G)
ZTE MF636
Internet key Momo Design
Dialup_without_a_dialer_HOWTO
3G and GPRS modems with pppd alone
Huawei E1550 3G modem