Mobile broadband repeatedly connects/disconnects

ltemodemnetworkingnetworkmanagersuspend

I'm using Verizon mobile broadband with a Sierra Wireless EM7345 4G LTE modem built into a Thinkpad T450s laptop. I'm configuring the modem with NetworkManager and ModemManager, using one of the default settings (APN vzwinternet). The machine is running up-to-date Arch Linux, with kernel version 4.1.4.

The modem generally works fine when I first boot my machine. However, after I've suspended the machine to RAM for the first time, when I try to use the modem it repeatedly connects and disconnects, constantly changing IP address and making it impossible to use ssh. The only fix I've found is to reboot the machine. Obviously I'd like to fix this without rebooting.

If it's relevant, I have tlp enabled, but disabling it with tlp false doesn't fix the problem. Also, I've set USB_BLACKLIST_WWAN=1 in /etc/default/tlp, just in case. None of those changes seem to fix the problem.

For what it's worth, the reason for the disconnection appears to be no-carrier. I get a lot of this in my log, but the modem is often briefly usable between disconnects:

Aug 18 15:57:01 laptop NetworkManager[630]: <info>  (cdc-wdm0): Activation: successful, device activ
ated.
Aug 18 15:57:01 laptop nm-dispatcher[9896]: Dispatching action 'up' for wwan0
Aug 18 15:57:04 laptop ModemManager[613]: <info>  Modem /org/freedesktop/ModemManager1/Modem/2: stat
e changed (connected -> registered)
Aug 18 15:57:04 laptop NetworkManager[630]: <info>  (cdc-wdm0): modem state changed, 'connected' -->
 'registered' (reason: user-requested)
Aug 18 15:57:04 laptop NetworkManager[630]: <info>  (cdc-wdm0): device state change: activated -> fa
iled (reason 'modem-no-carrier') [100 120 25]
Aug 18 15:57:04 laptop NetworkManager[630]: <info>  NetworkManager state is now CONNECTED_LOCAL
Aug 18 15:57:04 laptop NetworkManager[630]: <info>  NetworkManager state is now DISCONNECTED
Aug 18 15:57:04 laptop NetworkManager[630]: <warn>  (cdc-wdm0): Activation: failed for connection 'V
erizon'
Aug 18 15:57:04 laptop NetworkManager[630]: <info>  (cdc-wdm0): device state change: failed -> disco
nnected (reason 'none') [120 30 0]
Aug 18 15:57:04 laptop NetworkManager[630]: <info>  Writing DNS information to /usr/bin/resolvconf
Aug 18 15:57:04 laptop nm-dispatcher[9896]: Dispatching action 'down' for wwan0

Best Answer

Okay, I've finally after years of immense frustration managed to solve the problem, which is that NetworkManager is just really buggy about modems. In fact, recently it has gotten worse and even started segfaulting when my broadband modem is up. However, it turns out that if you just configure the modem manually, it works super well, even after a sleep. (You have to reconnect when waking up from sleep, but it reconnects quickly and then works stably.)

The following instructions assume you are running as root. The first step is to get NetworkManager out of the way. To do that, edit the file /etc/NetworkManager/NetworkManager.conf and add the following:

[keyfile]
unmanaged-devices=interface-name:cdc-wdm0

Note that if you want it to ignore multiple devices, you can separate them with a semicolon. Next, you have to configure the APN (and mbim-proxy) as follows. Look at /usr/share/mobile-broadband-provider-info/serviceproviders.xml (or the online git repository) to find the appropriate APN for your network. In the case of verizon wireless, that's vzwinternet. Once you have that, create a file /etc/mbim-network.conf with the following:

APN=vzwinternet
PROXY=yes

Now run the following:

rfkill unblock wwan
mbim-network /dev/cdc-wdm0 start
ip link set wwan0 up
mbimcli -p -d /dev/cdc-wdm0 --query-ip-configuration

If the mbim-network command succeeds, the mbimcli command will subsequently produce output like the following:

[/dev/cdc-wdm0] IPv4 configuration available: 'address, gateway, dns'
     IP [0]: '100.125.243.196/24'
    Gateway: '100.125.243.1'
    DNS [0]: '198.224.173.135'
    DNS [1]: '198.224.174.135'
    DNS [2]: '198.224.173.135'
    DNS [3]: '198.224.174.135'

[/dev/cdc-wdm0] IPv6 configuration available: 'address, gateway, dns'
     IP [0]: 'fe80::69:1c7d:5901/120'
    Gateway: 'fe80::69:1c7d:5902'
    DNS [0]: '2001:4888:68:ff00:608:d::'
    DNS [1]: '2001:4888:61:ff00:604:d::'

Now just manually configure those values on your network interface and it will work. E.g.:

ip addr add dev wwan0 100.125.243.196/24
ip route add default via 100.125.243.1
echo 'nameserver 198.224.173.135' > /etc/resolv.conf

Do not attempt to run DHCP (it won't work). Do not attempt to ping the gateway (100.125.243.1) as that won't work either. The fact that the gateway doesn't respond to any network packets (and might not even exist) made me think that my modem wasn't working, until I finally tried adding the default route and disabling my other network connection.

Related Question