2

I have a USB modem (Huawei E1552) connected a RPi running Raspbian Stretch. It is connected at remote location that needs persistent internet. For example, for ssh or pushing code remotely.

I have managed to get it "working" using wvdial and a couple of lines in /etc/profile to get it to automatically to connect on reboot. It is very very cruel and I would like it to have some fail safe (e.g. reconnect on lost connection). The profile looks like this:

echo waiting for device to boot...
sleep 10
screen -S APN -dm sudo wvdial defaults
echo adding to route...
sleep 10
sudo route add default dev ppp0 

Can someone suggest a better method? I am not very familiar with Linux.

I have also tried the qmi method here but it did not work for me. I think the /etc/network/interface is now deprecated?

Thanks!

6
  • Questions: (1) Is your model EXACTLY this one: AliExpress Unlocked Huawei E1552 3G WCDMA/HSDPA/UMTS 2100MHz Wireless Modem USB Dongle Supports SMS Service - US$15 ( alibaba.com/product-detail/… ) (2) If you software/bash shutdown and reboot, wll Rpi automatically connect? (3) If you hardware/power reset (say, manually switch off and then switch on 5V DC power, will Rpi automatically connect?
    – tlfong01
    Jul 5, 2019 at 5:23
  • 1) It does not look exactly like that one, as in it is a local carrier branded. 2) Yes 3) Yes It seems to reconnect in those situations. Maybe all I need is to call wvdial from a bash script in a while loop like wiki.archlinux.org/index.php/Wvdial#Auto_Reconnect suggests? Jul 5, 2019 at 7:14
  • Ah the look is not important. What is important is the model number and the spec. Sometimes OEMs products have same model number might have different options or spec. Of course you can use wvdial to connect. But what can you do if your Rpi freezes for some reason, and your bash script is dead?
    – tlfong01
    Jul 5, 2019 at 7:33
  • So you need a software watchdog timer to automatically reset Rpi, in case it freezes. Or you can use a hardware realtime clock such as DS3231 RTC module to reset Rpi every 1200 midnight, (2) Or use another slave Rpi detecting master Rpi freezes, then use a GPIO pin to reset master Rpi.
    – tlfong01
    Jul 6, 2019 at 1:27
  • I actually do have a hardware switch right now! I will have a look at this more in term of some fault tolerance on the bash and wvdial side. Glad to see I am not crazy in the head! Jul 7, 2019 at 4:53

1 Answer 1

1

Try following this tutorial, it helped me bring ppp0 elegantly and it has a connection watchdog. I haven't tested that part, but it looks like it would do the trick.

Basically you can create an entry in /etc/network/interfaces or a file in /etc/network/interfaces.d setting up ppp0

Mine is as follows:

auto ppp0
iface ppp0 inet wvdial
provider vodafone #the name you configured for wvdial
pre-up /etc/ppp/wait-dialup-hardware ttyUSB0 20
pre-up /etc/ppp/wait-dialup-hardware ttyUSB1 20
pre-up /etc/ppp/wait-dialup-hardware ttyUSB2 20
pre-up sleep 30
post-up echo "3G (ppp0) is online"

You could then add another post-up action that could run another script with the command route add default dev ppp0

1
  • 1
    We're looking for long answers that provide some explanation and context. Don't just give a short meaningless answer, only with a link (link-only answer); explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed or you risk to get down votes.
    – Ingo
    Mar 25, 2020 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.