Recent 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.
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:
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.
Replace with your own ISP provided user name or remove this line if your ISP isn't using authentication.
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.
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.
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 22.214.171.124 nameserver 126.96.36.199
Then you would need to remove "usepeerdns" line from your peers file and add something like:
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".
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!