1

I have a Raspberry Pi 3 device to which I have added a MultiTech MTQ-LAT3-B02 modem. I am able to successfully use pppd to connect to the cellular network. I then can add a ppp0 route and successfully use the cellular as a backup route to the internet when I lose the main eth0 connectivity. This works.

The problem: This approach leaves an open connection to the cellular network.

The question: How can I configure the cellular pppd to only connect (and subsequently disconnect after some idle timeout) when needed. That being when eth0 is down and there is something that needs to send data to the Internet. I have toyed with the ppp option "demand", but that does not seem to work as I think that is really intended for dial-up implementations.

Here is the Raspbian Version:

Linux raspberrypi 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux

Here are my ppp option settings:

debug
lcp-echo-failure 3
lcp-echo-interval 3
nomagic
/dev/ttyACM3
460800
crtscts
noauth
noipdefault
ipcp-accept-local
ipcp-accept-remote
usepeerdns
novj
nobsdcomp
novjccomp
nopcomp
noaccomp
lock
connect "/usr/sbin/chat -v -f /etc/ppp/peers/multitech-chat"
defaultroute
nodeflate
updetach

Any advice is appreciated.

0

I was solving the same problem and found the solution.

The first question you should ask yourself is how will you find out that internet connection on ethernet is working even when you are actually connected throuhg cellular network.

This is a crucial part to solve how to disconnect from cellular once cable connection will start working again.

I used a small trick. I selected some reliable IP address which I could ping (e.g. public dns server or whatever) and used policy based routing in linux to route traffic to this IP address always through cable network.

You can see my example of policy based routing in this ifup script - https://github.com/koss822/misc/blob/master/WirelessSwitch/install/ifup.sh

After you set-up policy based routing for e.g. IP 4.2.2.2 you can start ping this address continuously. By pinging this IP which is routed using policy based routing you will know if your cable connection is working or not.

Now you have to write switch script which will continuously ping the IP address and in case it will become unreachable more than 5 pings in row switch to cellular. Also if you are switched to cellular and the IP will become reachable, you have to disconnect from cellular.

I wrote script for it in Python - https://github.com/koss822/misc/blob/master/WirelessSwitch/rpicontrol.py

Unfortunately this was part of a project I made 3 years ago and there is not much documentation available. Basically you can get inspired by my work but I cannot provide you complete working tutorial.

If you get it working and would like to help to document it for others, please contact me and I will publish it on my wiki - http://www.enigma14.eu/wiki/

Have a good luck!

  • Instead of policy based routing, I suspect you could just ping -I eth0 known.good.server to force the ping to use the Ethernet interface. – Heath Raftery Apr 24 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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