# Wireless wan (mobile broadband) configuration, netifrc

## Zarhan

Hi,

  how are you supposed to configure a wireless WAN connection to a laptop (in this case a Thinkpad with Sierra Wireless WAN card)?

  I can see that there's a network interface wwan0 with ifconfig. I would guess you can just do the standard ln -s net.lo net.wwan0 under init.d to get the networking script operational.

  However, how do you bring that up once I get a SIM card in place? E.g.

  - How to unlock the SIM (send PIN)

  - How to read SMS

  and so on.

  I can create and acpid script/action to bind bringing up the interface to an Fn key, so no problem there.

----------

## Ant P.

You probably need to install and configure net-dialup/ppp. For SMS look at app-mobilephone/smstools.

----------

## Zarhan

Already have those, but it seems that there really is no interface for accessing the AT command interface of the modem. There are no /dev/ttyUSBX devices present.

----------

## charles17

 *Zarhan wrote:*   

> how are you supposed to configure a wireless WAN connection to a laptop (in this case a Thinkpad with Sierra Wireless WAN card)?

 

Would you please show us how that card appears in dmesg, lsusb, lspci, ifconfig -a, ...?

----------

## Zarhan

This is pretty much it. The options mentioned in the wikilink are installed.

lsusb:

```
Bus 001 Device 007: ID 1199:9079 Sierra Wireless, Inc. 
```

dmesg:

```
[    1.617693] usbcore: registered new interface driver cdc_ncm

[    1.617700] usbcore: registered new interface driver cdc_mbim

[    1.621754] usbcore: registered new interface driver cdc_acm

[    1.621755] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

[    1.621761] usbcore: registered new interface driver cdc_wdm

[    5.056619] cdc_mbim 1-6:1.12: cdc-wdm0: USB WDM device

[    5.056720] cdc_mbim 1-6:1.12 wwan0: register 'cdc_mbim' at usb-0000:00:14.0-6, CDC MBIM, 3a:15:28:0b:c5:79

[    5.405493] usbcore: registered new interface driver qcserial

[    5.405499] usbserial: USB Serial support registered for Qualcomm USB modem

```

----------

## NeddySeagoon

Zarhan,

You need some of this

```
config USB_NET_QMI_WWAN

        tristate "QMI WWAN driver for Qualcomm MSM based 3G and LTE modems"

        depends on USB_USBNET

        select USB_WDM

        help

          Support WWAN LTE/3G devices based on Qualcomm Mobile Data Modem

          (MDM) chipsets.  Examples of such devices are

            * Huawei E392/E398

          This driver will only drive the ethernet part of the chips.

          The devices require additional configuration to be usable.

          Multiple management interfaces with linux drivers are

          available:

            * option: AT commands on /dev/ttyUSBx

            * cdc-wdm: Qualcomm MSM Interface (QMI) protocol on /dev/cdc-wdmx

          A modem manager with support for QMI is recommended.

          To compile this driver as a module, choose M here: the

          module will be called qmi_wwan.
```

Do you have /dev/ttyUSBx so you can use AT commands to gen the link up or /dev/cdc-wdmx so you can use the proprietary protocol?

The conventional setup is AT commands over the serial link to cover unlocking the SIM, dialling and authenticating , then start PPP to use Ethernet on the link.

-- edit --

```
 * option: AT commands on /dev/ttyUSBx
```

 As a wild guess, I think that refers to the kernel module named option.

I need that for my USB 3G dongle to get the serial ports.

----------

## Zarhan

I had enabled USB_SIERRA_NET since that's supposed to be the driver. I now added the Qualcomm driver as well. Qcserial is now loaded at boot, and /dev/cdc-wdm0 device does appear. The ttyUSB devices are still missing.

The laptop is actually a Thinkpad T470, forgot to mention that.

----------

## Zarhan

Ok, looks like the ttyUSBX interfaces are not necessarily needed.

However, lots of links, eg. http://www.embeddedpi.com/documentation/3g-4g-modems/raspberry-pi-sierra-wireless-mc7304-modem-qmi-interface-setup talk about qmiutils package, and that does not seem to be available for Gentoo. What to do now?

----------

## NeddySeagoon

Zarhan,

If you can find a tool to drive it  /dev/cdc-wdm0 cam be used to establish the link.  Its a proprietary protocol though.

If not, you need the USB serial devices.  That probably needs 

```
CONFIG_USB_SERIAL_OPTION
```

in the kernel.

----------

## Zarhan

I have USB_SERIAL enabled (due to the fact that I have a USB to serial converter as well). I now added USB_SERIAL_GENERIC and USB_SERIAL_SIMPLE, as well as USB_SERIAL_QCAUX and USB_SERIAL_QUALCOMM, and also USB_SERIAL_SIERRAWIRELESS.

None of the above helped.

----------

## Zarhan

Oh, turns out libqmi is actually included with Gentoo. I just had to enable use flag mbim.

So, I can control it at least with qmicli -d /dev/cdc-wdm0.

Thanks for all the pointers. Looks like this card does no longer even support the old serial interface.

----------

## Zarhan

Just in case someone else would need it, I got this thing streamlined. 

I created a new network init script using standard method, that is ln -s net.lo net.wwan0.

Then, in /etc/conf.d/net, I added the following functions. I used this https://gist.github.com/ploth/556ef1620be411c8f66f96b9fc570bb3 as a starting point. However, I opted to use modemmanager instead of mbim_cli to handle most of the low-level stuff. Only figuring out the IP and DNS parameters are from mbim_cli.

This assumes that modemmanager is running. The modemmanager package doesn't provide init script to start it as service, but one can use this one here:

https://forums.gentoo.org/viewtopic-p-7633094.html#7633094

Why I don't use networkmanager? Well, I want my network to be available before login.

```
preup() {

  if [[ ${IFACE} == "wwan0" ]] ; then

    rfkill_device=$(rfkill list | grep tpacpi_wwan_sw | awk 'BEGIN { FS = ":" } ; { print $1 }')

    rfkill unblock ${rfkill_device}

    mmcli -m 0 --simple-connect="apn=internet"

    query=$(mbimcli -d /dev/cdc-wdm0 -p  --query-ip-configuration)

    squery=($query) #split into array elements

    ipv4=$(echo ${squery[10]} | sed s/\'//g)

    gwv4=$(echo ${squery[12]} | sed s/\'//g)

    d1v4=$(echo ${squery[15]} | sed s/\'//g)

    d2v4=$(echo ${squery[18]} | sed s/\'//g)

    ipv6=$(echo ${squery[31]} | sed s/\'//g)

    gwv6=$(echo ${squery[33]} | sed s/\'//g)

    d1v6=$(echo ${squery[36]} | sed s/\'//g)

    d2v6=$(echo ${squery[39]} | sed s/\'//g)

    if [[ $2 == '' || $2 == '4' ]]; then

      # ipv4

      ip addr add $ipv4 dev wwan0

      echo -e "nameserver $d1v4\nnameserver $d2v4" | resolvconf -a wwan0.lte

      # activate device

      ip link set wwan0 up

      ip route add default via $gwv4 metric 50

    elif [[ $2 == '6' ]]; then

      # ipv6

      ip addr add $ipv6 dev wwan0

      echo -e "nameserver $d1v6\nnameserver $d2v6" | resolvconf -a wwan0.lte

      # activate device

      ip link set wwan0 up

      ip route add default via $gwv6 metric 50

    fi  

  fi

}

predown() {

  if [[ ${IFACE} == "wwan0" ]] ; then

    mmcli -m 0 --simple-disconnect

    # deactivate device

    ip link set wwan0 down

    ip add flush dev wwan0

    resolvconf -d wwan0.lte

    mmcli -m 0 -d

    rfkill_device=$(rfkill list | grep tpacpi_wwan_sw | awk 'BEGIN { FS = ":" } ; { print $1 }')

    rfkill block ${rfkill_device}

  fi

}

```

----------

## Maxwell

Hi Zarhan

The gist provided is no longer available. Could you be so kind and provide your /etc/conf.d/net file?

Trying to use a Vodafone branded huawei e398 usb stick on a raspberry pi/arm sbc

----------

## Ant P.

Nowadays I'd recommend using net-misc/connman[+ofono] instead. It seems to be good at handling exotic dialup setups.

----------

