2

I am trying to establish a 3G connection with Raspbian, a 3G USB dongle, usb_modeswitch and wvdial. I followed this tutorial which has worked well before with a different 3G dongle.

My 3G dongle is a ZTE D6601, the SIM has no PIN and the connection works flawlessly with the ISPs tool under Windows and under Ubuntu 15 with the built-in mobile broadband tool. But I need to do this on a Raspberry Pi and from the command line.

This is what I have tried so far: When I boot Raspbian, lsusb returns

Bus 001 Device 004: ID 19d2:0154 ZTE WCDMA Technologies MSM 

I then run

sudo usb_modeswitch -I -v 19d2 -p 0154 -c /etc/usb_modeswitch.conf 

Which changes the ProductID to

Bus 001 Device 009: ID 19d2:0108 ZTE WCDMA Technologies MSM 

There is more than one 3G dongle with 0154 as DefaultProduct ID so the standard switching rules of usb_modeswitch don't work. 0108 is what Ubuntu switches the device to or what happens when I sudo eject the virtual CD drive, so I used that.

My /etc/network/interfaces was only changed to use a WiFi connection:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

So far, so good. When I run sudo wvdialconf, a modem is detected at /dev/ttyUSB1. I then run sudo wvdial dcom with dcom being defined like this (APN "e-connect" is correct, no user / pass required):

[Dialer dcom]
Modem = /dev/ttyUSB1
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","e-connect"
Stupid Mode = 1
Modem Type = Analog Modem
Phone = *99#
ISDN = 0
Username = { }
Auto Reconnect = 1
Password = { }
Baud = 460800

The shell returns this:

--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
OK
--> Sending: ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: AT+CGDCONT=1,"IP","e-connect"
AT+CGDCONT=1,"IP","e-connect"
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT 21600000
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Sat Apr 25 18:09:08 2015
--> Pid of pppd: 5530
--> Using interface ppp0
--> pppd: [08]FX[01]�FX[01]8GX[01]p<X[01]�PX[01]�QX[01] (+4 more times)

After running this, ifconfig shows that ppp0 was created but no IP address is assigned. Then, about 10 seconds later this happens:

--> Disconnecting at Sat Apr 25 18:09:39 2015
--> The PPP daemon has died: A modem hung up the phone (exit code = 16)
--> man pppd explains pppd error codes in more detail.
--> Try again and look into /var/log/messages and the wvdial and pppd man pages for more information.
--> Auto Reconnect will be attempted in 5 seconds
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: AT+CGDCONT=1,"IP","e-connect"
AT+CGDCONT=1,"IP","e-connect"
OK
--> Modem initialized.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: AT+CGDCONT=1,"IP","e-connect"
AT+CGDCONT=1,"IP","e-connect"
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
ERROR
--> Invalid dial command.
--> Disconnecting at Sat Apr 25 18:09:45 2015

If I run wvdial dcom again, it will repeat the output of the second connection attempt above (Invalid dial command) and not even configure ppp0. Weirdly, after a quick sudo wvdialconf (during which /etv/wvdial.conf remains unchanged), I can connect again, but it will again assign no IP and break after 10 seconds. I have replicated this several times.

Maybe this is also interesting: wlan0 loses its IP the moment ppp0 is created and I can only get it back running sudo ifdown wlan0 and sudo ifup wlan0 even though it is set to automatically reconnect.

1 Answer 1

0

I finally figured out a way: I dropped wvdial and used nmcli (from the network-manager package) instead. I established the connection 10 hours ago and it is still active with the same IP. Here's how I did it:

Step 1: Get usb-modeswitch to run so your 3G USB stick is recognized as a modem, not a storage device. I am not going to cover the details here as there are many tutorials out there (example).

Step 2: Install NetworkManager on the RPi: sudo apt-get install network-manager network-manager-gnome -y. Check whether NetworkManager recognizes your modem by running nmcli dev. If yes, you should see a table like this:

DEVICE        TYPE                      STATE
ttyUSB2        gsm                      disconnected

(If no, your usb-modeswitch may have failed and your system cannot find a modem.)

Step 3: Start the X server: startx, open the NetworkManager from the menu and create a new "Mobile Broadband" connection ("Mobile Broadband" tab > "Add"). The wizard will guide you through the process even letting you select your provider so you don't have to bother with APN settings. The tool will create a connection file in /etc/NetworkManager/system-connections/ and you should take note of the name of that file as it will be used as the connection name in the next step.

Step 4: As I said in my question, I need to be able to run this from the command line without the X server and the way to do that is by running sudo nmcli con up id "Connection ID", the connection ID being the name of the connection you created in step 2. That should be all. To disconnect, execute sudo nmcli con down id "Connection ID".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .