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

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!

DevGenii

A quality focused Magento specialized web development agency. Get in touch!

16 thoughts on “Manage GSM mobile broadband connections without Network Manager (Ubuntu, Linux Mint, Debian)

  1. Andreichiver

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

    Cheers!

    Reply
    1. Marko

      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.

      Reply
  2. Amit Shreyas

    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…

    Reply
  3. dian n.

    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..

    Reply
  4. Lope

    Hi thank you for sharing this info!
    I’ve followed your guide exactly and when I type sudo pon e220v I get no output in the console. I could not find any non-empty logs in /var/log named *ppp/pap/pon/chap*.

    here are the config files I created:
    http://codepad.org/lIz5xz2Y

    Reply
  5. Lope

    I forgot to mention.
    I’m running Linux Mint 15 x64 with Mate.
    Earlier today I fiddled around with sakis3g, but just got errors.
    Then I connected fine a few times with modem-manager/network manager.
    But after a few disconnects/reconnects (testing) it just will not connect. I’ve rebooted as well.

    That “sudo pon e220v” command does absolutely nothing, doesn’t even make the light flash.

    I’ve tried multiple sim cards (all have credit on them) and after I plug in I wait after the light has finished flashing green and then flashes blue occasionally. (meaning its on the network). My sims don’t have any PIN codes on them.

    [0] % lsusb | grep E220
    Bus 003 Device 002: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E230/E270/E870 HSDPA/HSUPA Modem

    Reply
  6. Lope

    I’ve also got the Huawei E173 and some other brand to test with. But I’d like to get some life out of the E220 first. Even an error message would be better than nothing.
    Thanks again 🙂

    Reply
  7. Lope

    After wasting a huge part of my day on this I realized I’ve been plugging these huawei dongles into a USB3 port, and clearly they’re not compatible with USB3.

    It was only after successfully testing on an older laptop with W7. And then dual booting my main machine to W7 and finding the dongles didn’t work on my main machine that I started to smell a USB port rat.

    I’m not going to bother with any of this stuff now. I’m so over computers right now.

    Reply
  8. heff

    Thank you very much for this post.

    It was very helpful for me. after more then 6 mounts of attempts I could thnks to this post to connect using my GSM mobile (Motorola L6) on Mint 13. the problrm Now is to get G3 USB Modems working (Unrecognized modem: only recogonized  as storage media not as a modem !!!!!!! I made it work on Ubuntu 10.04 some years ago but on Mint 13  it seems to be hard).

    Reply
  9. Oliver

    Dear Marco.

    MANY, MANY, MANY thanks for this description. I were sitting
    * yesterday for ~6 hours, and
    * today for another ~6 hours,
    to get a stable mobile broadband connection from my laptop with the networkmanager. And it worked only some times – and I was not able to figure out, why it was not always working.

    Then I found and read this description. I implemented it, and until now every connection try was working!

    The description is perfectly documented, and easy to understand. It took me about 30 minutes to read, understand, and implement everything.

    Again thank you very much for this description!

    Just for information of my system:
    System: Kernel: 3.13.0-37-generic x86_64 (64 bit, gcc: 4.8.2)
    Desktop: Gnome Distro: Linux Mint 17.1 Rebecca
    Machine: System: Hewlett-Packard (portable) product: HP Pavilion 17 Notebook PC
    Hewlett-Packard 17-f151ng (K0W64EA)
    CPU: Quad core AMD A8-6410 APU with AMD Radeon R5 Graphics
    USB-Modem-Stick: Company: MEDION
    Type: S4222
    Link:
    Telecommunication service company: Hofer Telekom (HoT)
    Link:

    Thank you and regards,
    Oliver.

    Reply
  10. Amir

    Hi,

    I read your comments, I wondering if i can get SIB (System Information Block) data by a USB Modem such as Huawei E3372?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *