Mobile broadband from the command line in Ubuntu

For people who want to use their HSDPA connection from the command line in Ubuntu – Perhaps you have a server you want to use it on, or perhaps you want to do it from the command line for the craic – This is for you.

There are 3 files involved “/etc/ppp/peers/provider”, “/etc/chatscripts/pap” and “/etc/ppp/chap-secrets”.

#/etc/ppp/peers/provider

user "user"
connect "/usr/sbin/chat -v -f /etc/chatscripts/pap -T *99#"

# Serial device to which the modem is connected.

/dev/ttyUSB0

# Try to get the name server addresses from the ISP.

usepeerdns

# Use this connection as the default route.

defaultroute
replacedefaultroute

# Makes pppd "dial again" when the connection is lost.

persist

# no compression - ppp is used only until the modem

novj
novjccomp
nopcomp
nodeflate
noccp
#debug

“/etc/chatscripts/pap”:-

ABORT           BUSY
ABORT           VOICE
ABORT           "NO CARRIER"
ABORT           "NO DIALTONE"
ABORT           "NO DIAL TONE"
""              ATZ
OK ATE0V1&D2&C1S0=0+IFC=2,2
OK AT+CGDCONT=1,"IP","3internet"
OK ATDT*99#
CONNECT         ""

“/etc/ppp/chap-secrets”:-

# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
3ireland        *       3ireland

The most important setting is for the APN in the chat script “3internet”, change this to suit your own provider. You may also need to change usernames and passwords. Until you are confident the connection is working correctly you may also want to enable debugging by uncommenting “#debug” in /etc/ppp/peers/provider. Commonly with 3 the DNS servers don’t get doled out correctly so it may be wise to comment “usepeerdns” and put the DNS servers for your connection into “/etc/resolv.conf” manually.

To start the connection simply type “pon”, to stop conversely “poff”. To start the connection on boot add “pon” to “/etc/rc.local”. To share the connection enable ip forwarding in “/etc/sysctl.conf” and have iptables configured correctly. See http://www.johnlewis.ie/the-importance-of-a-minimal-firewall/ for more information on the firewall side.

Join the conversation

4 Comments

  1. Hi, John .

    I’d like to ask if you could help out with a note :

    I am using Mobile Broadband regularly for access to the internet through Qualcomm Gobi Cards ( times via some sticks , too ) since they exist .

    My problem is : I am not deep-thought-and-taught enough to understand the concept of networking on the core-level, especially in linux ( in my case SUSE since 4 / Ubuntu since Feisty / Fedora since 6 ) ; :) Yeah i know, it might seem i’m just lazy, but i just never got it , really .

    So to my question :
    What is the ( in core based on the same pattern ) cross-compatible way of setup and which packages are needed to have mobile broadband with either my gobi cards and/or sticks for 2G/3G/LTE , to connect to the internet from BOOT on ?

    And if possible: how can i EXCLUSIVELY use mobile broadband ? ( As for now i’m hung with the network-manager and i wish to toggle activity for networking cards INDEPENDENT from each other ) .

    Could you briefly explain the logic behind networking in linux from my perspective of usage ?

    Thanks.

    PAETH CLAUDIUS RAPHAEL

    1. The bare minimum you need is PPP package and a recent kernel. Set up in the correct way, that will work regardless of distro-specifics.

      Unless you are using policy based routing you will only have one default route to the internet, so I don’t quite understand that question – as long as “defaultroute” is set in the PPP config for mobile broadband, the mobile broadband will become the way the internet is contacted.

      I don’t know what your perspective of usage is. Do you know anything about TCP/IP?

Leave a comment