'4G USB Dongle Auto Reconnect / Auto Recover
I have a Raspberry Pi with a 4G USB dongle connected to it for internet access. Everything works on power-up, everything auto-connects and connectivity is established. In fact if I leave the Raspberry Pi on my desk powered up it stays connected through the 4G dongle for weeks without any issues. As soon as I leave my mobile cell area, connectivity drops out and does not recover. I also want to be able to unplug the USB 4G dongle and reconnect it and have the cell link auto recover. I am using USB-Modeswitch and wvdial. Is there anyway I can get the 4G dongle to auto recover?
Thanks for reading. Brodes.
Solution 1:[1]
OK I think I have found the solution I was looking for....
I created this script that sends 5 pings to the other end of a VPN tunnel. If the pings fail then the Raspberry Pi reboots.
#!/bin/bash
# This script checks for an active Internet connection by pinging.
# If the pings fail, it will reset the USB modem dongle.
ping -c5 10.8.0.1
let a=$?
if [ "$a" != "0" ]; then
/sbin/shutdown -r now Connection lost, rebooting...
fi
Then I created a cronjob to run this script every 2 minutes.
If anyone has a better idea please let me know.
Cheers,
Brodes.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |