Home » Linux » Manage GSM mobile broadband connections without Network Manager (Ubuntu, Linux Mint, Debian)

Manage GSM mobile broadband connections without Network Manager (Ubuntu, Linux Mint, Debian)

February 7th, 2012 Leave a comment Go to comments

Debian LogoRecent Network Manager versions like Network Manager 0.9.1 from Ubuntu 11.10 and Network Manager 0.9.2 from Fedora 16 and aren't working well with both of my GSM mobile broadband modems, Huawei E220 and ZTE MF100. Actually this aren't first Network Manager version that refuse to work with the same hardware, there were some problems back in the good old Ubuntu 9.10 days. Because of that I had to learn managing my mobile broadband network connections without Network Manager. In this article I will do my best to point you in the right direction to managing your GSM mobile broadband connections from terminal without Network Manager on Ubuntu, Linux Mint and Debian based operating systems.

Introduction

Back in the good old modem days (33.6K, 56K etc) we've used Point-to-Point Protocol daemon (man pppd) to dial to our ISP for network connection. Now we will use the same pppd to establish mobile broadband GSM connection. Actually if have ever monitored your syslog while Network Manager was dialing to your mobile broadband Internet service provider you've probably seen that Network Manager communicates with the same pppd to establish your GSM connection. Please keep in mind that pppd is versatile tool and that there isn't copy paste approach to using it. You will probably have to learn some basics about how point-to-point works and use logic and adjust my examples to your hardware and ISP configuration.

My hardware and ISP configuration

I will use Huawei E220 and ZTE MF100 GSM modems to connect to dummy ISP named "ispname" using dummy APN "ispapn" for access point name and password authentication protocol (PAP) authentication protocol. Most common configurations are without any authentication (you don't need to enter name and password when connecting to your ISP) or with Challenge-Handshake Authentication Protocol (CHAP) authentication protocol (also covered here).

Step by step procedure (Ubuntu, Linux Mint, Debian)

For later Ubuntu versions to get DNS features to work fine you will need to remove resolvconf package and create resolv.conf file manually. This package helps applications supporting it (like Network Manager) to work without resolv.conf. Since pppd doesn't support resolvconf it may be required to remove it. To do that you can use something like this:

sudo apt-get remove resolvconf
sudo touch /etc/resolv.conf

First we need to create so called chat script that will communicate directly to your modem hardware and configure things like access point name (APN), timeouts and calling number using AT commands. I will create file named "ispname" inside /etc/chatscripts/ directory to hold my chat script (replace "ispname" with your ISP name).

sudo nano /etc/chatscripts/ispname

Inside this file I will place following code:

TIMEOUT 10
ABORT 'BUSY'
ABORT 'NO ANSWER'
ABORT 'ERROR'
ABORT 'NO CARRIER'
 
'' 'ATZ'
'OK' 'ATE1'
'OK' 'AT+CGDCONT=1,"IP","ispapn","0.0.0.0",0,0'
'OK' 'ATDT*99#'
'CONNECT' '\c'

You should replace "ispapn" with your ISP access point name (APN.)

My ISP is using PAP authentication so I must add user name and password provided by my ISP at the end of my /etc/ppp/pap-secrets file.

sudo nano /etc/ppp/pap-secrets

If your Internet service provider is using CHAP authentication do the same but use /etc/ppp/chap-secrets file. Also we must decide on remote name identification string that will be used in the next steps to instruct pppd to use right pap or chap credentials. I will use string "ispname" here. So here's what I have placed at the end of my /etc/ppp/pap-secrets file (place your user name, password and string of your choice here instead of my "ispusername", "isppassword" and "ispname"):

"ispusername" "ispname" "isppassword"

If your ISP isn't using authentication and you don't need to provide name and password to connect to Internet you can skip this step altogether.

As a third step we must create so called peers file that will be used by pppd to dial chat script created in the first step using credentials stored in the second step. I will call my peers file "ispname" and place it into /etc/ppp/peers directory:

sudo nano /etc/ppp/peers/ispname

Inside my peers file I will place following code:

hide-password 
noauth
connect "/usr/sbin/chat -v -f /etc/chatscripts/ispname"
debug
/dev/ttyUSB0
115200
defaultroute
replacedefaultroute
noipdefault
usepeerdns
crtscts
lock
local
 
# Redial and interval
persist
holdoff 5
 
# No compression
novj
novjccomp
nopcomp
nodeflate
 
# PAP authentication
user "ispusername"
remotename ispname
refuse-chap
refuse-mschap
refuse-mschap-v2
refuse-eap
 
# LCP echo messages settings
lcp-echo-failure 4
lcp-echo-interval 65535

Description for all these settings are available on pppd man page (man pppd), I will explain settings you will most likely need to adjust for your ISP and hardware:

/dev/ttyUSB0

virtual serial port created by your GSM modem device. You will select /dev/ttyUSB0 if you have Huawei E220 device or /dev/ttyUSB2 if you have ZTE MF100 modem device. If you have some other modem device take a look at the “Connection information” window from your Network Manager when you have established Internet connection using Network Manager. That will give you serial device location for your hardware.

user "ispusername"

Replace with your own ISP provided user name or remove this line if your ISP isn't using authentication.

remotename ispname

Here you will place remote name identification string from /etc/ppp/pap-secrets or /etc/ppp/chap-secrets ("ispname" in my case) or you will remove this line if your ISP isn't using authentication.

"refuse-X" lines

You will need to modify this for your ISP authentication protocol. You instruct pppd to refuse all authentication protocols except the one you are instructed by your ISP to use (PAP authentication in my case). If your ISP is using CHAP authentication you would modify my example by removing "refuse-chap" line and adding "refuse-pap" line. If your ISP isn't using authentication you just remove all lines "refuse-X" lines from peers file.

usepeerdns

due to usepeerdns option my example provided here is requesting DNS information from my ISP. To use your own DNS info, for example Google public DNS or OpenDNS, you will create file inside /etc/ppp/resolv directory. For example to use Google public DNS servers I would create /etc/ppp/resolv/google file and place following code inside:

nameserver 8.8.8.8
nameserver 8.8.4.4

Then you would need to remove "usepeerdns" line from your peers file and add something like:

ipparam google

where google is the name of your file inside /etc/ppp/resolv directory ("google" in my case). I recommend configuring manual DNS settings later when you are sure that everything works with "usepeerdns".

Additional configuration

This is basic configuration to get you online. To dial your connection you would use sudo pon ispname and to disconnect you would use sudo poff ispname where "ispname" is you peers file name. To be able to dial without sudo you need to add your self to "dialout" group:

sudo adduser $USER dialout

Further you might want to create interface for your pppd connection so you could control your GSM mobile broadband connection using "ifup" and "ifdown" commands and/or dial automatically when your PC boot. You would achieve this by adding something like this to your /etc/network/interfaces file:

auto ppp0
iface ppp0 inet ppp
	pre-up sleep 10
	provider ispname

In this example "ispname" is your peers file name. pre-up sleep 10 line is here to circumvent situation where your interface is being brought up during boot while your USB device isn't yet initialized. This line delays bringing this interface up for 10 seconds just to be on the safe side. If you don't want to automatically start this interface you can remove auto ppp0 and pre-up sleep 10 lines.

That's it for this how article. pppd is very powerful and all of this might look intimidating but once you set it up you will loose Network Manager dependency, learn a lot about point-to-point protocol and how Debian networking works. If something doesn't work first thing you should do is to consult man pppd because pppd has really good manual page. In my next article I will explain how to manage GSM mobile broadband connections without Network Manager on Red Hat Linux (RHEL), Centos and Fedora based operating systems. Good luck!

Categories: Linux
Comments
  • epiphany April 18, 2013 at 12:11:52

    you could use ixconn http://mwconn.net/info.html ………..or simply “sudo pppconfig” to make things easier.

  • dian n. March 9, 2013 at 07:53:09

    I was searching for software that can connect my huawei modem in debian squeeze for one week and finally I read your article, thanks a lot it works for me, my modem works flawlesly. Keep posting..

  • Hanynowsky October 22, 2012 at 01:12:07

    Great article. I did not think about using hardware directly without network manager which is indeed still immature!
    Thanks for the great job!

  • Amit Shreyas June 10, 2012 at 10:06:38

    please , also write an article for mobile-broadband-connection in Arch-linux.

    • Marko June 11, 2012 at 19:57:58

      Unfortunately I don’t have experience with Arch Linux. Did you try searching Arch wiki?

  • Amit Shreyas June 9, 2012 at 20:18:44

    very-very nice article… thanx…. network-manager problem was a subjact of depression for me. but now , i fixed it ,according to your article. now, i knew – how fast , strongly & easily , ppp connects to the network.

    And the Network -manager is useless for mobile-broadband -user.

    Thanx…

  • Andreichiver February 16, 2012 at 12:05:00

    Thanks a lot for this article, it was really helpful!!!
    It took me a while to realize that Network Manager was malfunctioning…

    Cheers!

    • Marko February 16, 2012 at 13:14:00

      It’s great to hear that. It took me a few days of man pages to put this together for my own hardware but I’m glad someone else found it useful.