How to setup a Safaricom modem on Ubuntu server 12

Recently I was supposed to install software on Ubuntu 12 server installation in Kapsabet, where there is no wired internet connection, we only had a Safaricom modem. Ubuntu server has no gnome GUI, and other tools that make connecting a modem in Ubuntu easy. This post describes how I went about connecting to the internet using a Safaricom modem on Ubuntu server 2012.

Wvdial

First thing was Google. Which lead me to a nifty tool called wvdial.

wvdial is an intelligent PPP dialer, which means that it dials a modem and starts PPP in order to connect to the Internet — wvdial man page

basically does what the inbuilt modem software does.

You need to download the source or the .deb file of wvdial from another computer (obviously). You also need to download its dependencies. This link was helpful in that venture, you need to install the dependencies in a specific order.

Once wvdial is installed and you have plugged in the the USB modem, a quick look at /dev/ using ls /dev/ shows that there is no /dev/USB0 this is because the device loads as a CD drive every time its plugged into a new computer so as to load the drivers. We need to make it switch from CD mode to USB mode, in order to connect to the internet.

Usb_switchmode

Enter usb_switchmode.

Several new USB devices have their proprietary Windows drivers onboard, most of them WAN dongles. When plugged in for the first time, they act like a flash storage and start installing the Windows driver from there. If the driver is already installed, it makes the storage device disappear and a new device, mainly composite with modem ports, shows up.
On Linux, in most cases the drivers are available as kernel modules, such as “usbserial” or “option”. However, the device shows up as “usb-storage” by default. usb_modeswitch can send a provided bulk message (most likely a mass storage command) to the device which is known to initiate the mode switching.

So we need to install it. Same drill, download usb_modeswitch and its dependencies. Once that is done, usb_modeswitch needs to know the product id and vendor id. You can get these by running the usb-devices command on the terminal.

usb-devices output

note the vendor and prodID. We will use these in the next command.

Now run sudo usb_modeswitch -p “prodID” -v “vendor” -H --type option-zerocd more info here.

  • -H flag uses preset configs for older huawei devices which was the one we were using. If it fails try -S.

Now you just one final thing

wvdial.conf

wvdial requires these configs in order to work with the Safaricom modem.

[Dialer Defaults]
Phone = *99#
Username = saf
Password = data
Stupid Mode = 1
Dial Command = ATDT
Modem = /dev/ttyUSB0
Baud = 3600000
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ISDN = 0
Modem Type = Analog Modem
Init4 = AT+CGDCONT=1,”IP”,”SAFARICOM"

Then just run wvdial on the terminal and you are set.

NB: remember to remove the pin from your sim-card(makes things easier).

Another helpful link. https://alaninkenya.org/2008/03/28/safaricom-huawei-e220-linux-and-you

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.