GSM ( ppp ) failover connection on an embedded debian device ( Pi / bbb/ cubieboard )

296 views
Skip to first unread message

Daniel de Kock

unread,
Sep 21, 2015, 1:57:47 AM9/21/15
to house4hack
Hihi,
teh device is running Armbian 4.3 with the Olimex / sunxi 3.4 kernel ( http://www.armbian.com/ )
I'm a bit stuck getting a device to dial a ppp connection if data does not go thru on Ethernet.

I've gotten it to work manually with wvdial, but not automate it.

does anyone know how one can do this so the device will attempt to use eth0, if the data doesnt go thru, dial ppp0 ( using wvdial or the non-wvdial pap and chat scripts way )
and if/when eth0 gets a connection again ( plugged into a router / router powers on again / gateway works again ) go back to using eth0 ?

I've read up about bonding the two interfaces but have not found a reliable way to bond ppp connections.

I have set up my /etc/network/interfaces  file that if eth0 goes down ( ifdown eth0 ) it will auto dial ppp,
when ett0 is brought up ( ifup eth0 ) it will hang up ppp0, but that is as far as i got..


Rogan Dawes

unread,
Sep 21, 2015, 6:33:38 AM9/21/15
to house4hack
I have done this successfully with an OpenWRT router, simply by adjusting the metrics of the routing.

i.e. set up your preferred route with a low metric, and your PPPo3G route with a higher metric. In principle, packets will prefer the route with the lower metric, so long as the preferred interface is up, your packets will take that route. When the preferred interface drops, packets will be routed via the route with the next lowest metric.

root@gateway:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         196.209.139.1   0.0.0.0         UG    10     0        0 pppoe-redafrica
0.0.0.0         192.168.202.1   0.0.0.0         UG    20     0        0 eth0.2
<snip>

In this case, eth0.2 happens to be my DLink 2500U, which is configured in bridging as well as ADSL router mode (with an FNBConnect free account), but no packets go that way unless my directly dialled RedAfrica account interface drops for some reason. The equivalent would apply for a 3G connection too, no doubt.

Rogan


--
--
You received this message because you are subscribed to the Google
Groups "house4hack" group.
To post to this group, send email to house...@googlegroups.com
To unsubscribe from this group, send email to
house4hack+...@googlegroups.com
---------------------------------------------------------------------------------------------
www.house4hack.co.za | Centurion Tue 18-21 & Sat 9-14 | Randburg Wed 18-21
---------------------------------------------------------------------------------------------
---
You received this message because you are subscribed to the Google Groups "house4hack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to house4hack+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

C.Lee Taylor

unread,
Sep 21, 2015, 7:22:46 AM9/21/15
to house...@googlegroups.com
Greetings ...

 I have done this on a CubieBoard using one of the Debian base distros. 

 I had my 3G PPP(oE) dial-up always running, for speed.  Seeing that you don't get charged for connection time.  Then increasing your Metric for the default route to the dial-up link.  This way you can still run ping and curl forced over both links to do Dynamic DNS updates for each link. Or in my case, VPN connections, so that I can connect to my device remotely.

 Problem I had with trying to do dial-on-demand, was I would get way to high packet loss while the PPP link was coming up.  You will have small amount of traffic running over the 3G link, but I felt the reduce fail over period was with the cost.

 From the interfaces man page

              metric metric
                     Routing metric for default gateway (integer)

Hope that helps.

Thanks
Mailed
LeeT

Daniel de Kock

unread,
Sep 21, 2015, 11:07:55 AM9/21/15
to house4hack, ro...@dawes.za.net
would I set the Metric for my eth0 connection in /etc/network/interfaces, and the same for ppp0 ?

( at the moment I call "pon" to start the dialler instead of letting the system do it through /etc/network/interfaces  's configuration.

to use the metric for failover behavior, i suppose I should remove "replacedefualtroute" and "defualtroute" from  /etc/ppp/options-mobile ?

( I followed this guide to  get it dialling without wvdial : https://wiki.archlinux.org/index.php/3G_and_GPRS_modems_with_pppd )

Rogan Dawes

unread,
Sep 21, 2015, 11:12:49 AM9/21/15
to house4hack

C.Lee Taylor

unread,
Sep 21, 2015, 11:27:52 AM9/21/15
to house...@googlegroups.com
That is a really good URL, with alot of useful info.

If I remember correctly, I did not set my PPP default router, but added post-up part.


Is a little old, but I think that is what I use as a base.

Then to do status/dyndns checks with curl, use curl --interface eth0 somefunkyurl vs curl --interface ppp0 someotherfunkyurl

Thanks
Mailed
LeeT

Gert van den Berg

unread,
Sep 23, 2015, 2:37:27 PM9/23/15
to house4hack
A lot depends on the setup...

Ideally you want to use some kind of routing protocol that quickly detects link failures.. This is usually not an option if it is a consumer-level internet connection...

The metrics might work, but Linux needs to be able to figure out when the link is down, which can be tricky if the ppp connection runs over the said ethernet connection... (Which would mean that the ppp connection is also useless since it needs the interface that is down...)

(With Cisco you can configure IPSLA probes that then cause the links to fail over, not sure about Linux)

If the ethernet simply run to a different router, unless you use some kind of probe, the link seems up unless the port goes down (cable unplugged or the connected switc goes down) (it MIGHT be able to use network / host unreachable ICMP messages from an upstream router as well...)

Gert van den Berg

unread,
Sep 23, 2015, 3:18:36 PM9/23/15
to house...@googlegroups.com
OSPF seems to be what you want... You need control of both ends of the
connections though... See
https://en.wikipedia.org/wiki/Open_Shortest_Path_First

(Routing protocols might still work for the ethernet... If you router
on the ethernet participates and advertise when it loses
conenctivity...)

An interesting hack might be to use BGP, which runs over TCP, unlike
most other routing protocols and use a much further server (that you
control) as the "adjacent server" that you exchange routes with... The
BGP sessions should then drop if the connection is unavailable, which
might allow the route to be removed... The drop might take > 1 minute
though... I'm not exactly sure how such a setup would work, it might
be intersting to try and build though... (If you have a proper
connection, you advertise your (public) IP range over both links over
BGP/another routing protocol to your ISPs and you router can figure
out if the links is down and from the ISP side they can route back to
you correctly as well...) (This likely requires an ISP-level internet
connection though...) (Or a private network...)

Gert

Rogan Dawes

unread,
Sep 24, 2015, 2:08:44 AM9/24/15
to house...@googlegroups.com

You can configure pppd with various options to check that the link is alive, and exit after a suitable time if it doesn't get the response from the remote end. If the interface drops, then the routing metrics mentioned previously come into play.

Rogan


Gert van den Berg

unread,
Sep 24, 2015, 2:30:18 AM9/24/15
to house4hack, ro...@dawes.za.net


On Thursday, September 24, 2015 at 8:08:44 AM UTC+2, Rogan Dawes wrote:

You can configure pppd with various options to check that the link is alive, and exit after a suitable time if it doesn't get the response from the remote end. If the interface drops, then the routing metrics mentioned previously come into play.


Correct, except that the Ethernet is the high-priority link in this case....

(If it is a simple internet connection and the router is running something like DD-WRT, it should be possible to let it advertise its link state using a routing protocol towards the LAN though (basically, when the pppoe connection from the router drops, stop advertising the default route...)) 

Rogan Dawes

unread,
Sep 24, 2015, 2:32:24 AM9/24/15
to house4hack

Ah, yes, I forgot the op wanted failover from Ethernet to 3g.

Rogan


--

Daniel de Kock

unread,
Sep 24, 2015, 7:54:31 AM9/24/15
to house4hack, ro...@dawes.za.net

Yep,
The idea is that if these units are installed where there is an Ethernet connection it will use that for its data, if that fails or it is on a vehicle it will use the Cellular modem ( ppp over /dev/ttyACM0 ) Photo is the first one we made.

I'm not sure if its the sunxi networking driver voodoo but it doesn't detect that the Ethernet has gone down  ( it reports  <6>PHY: sunxi_gmac-0:01 - Link is Down<c> )
ifconfig reports that the link is still up and the route is still in my routing table after the cable has been unplugged..

Gert van den Berg

unread,
Sep 24, 2015, 7:59:27 AM9/24/15
to house...@googlegroups.com, ro...@dawes.za.net


On 24 Sep 2015 13:54, "Daniel de Kock" <dekock...@gmail.com> wrote:
>
> Yep,
> The idea is that if these units are installed where there is an Ethernet connection it will use that for its data, if that fails or it is on a vehicle it will use the Cellular modem ( ppp over /dev/ttyACM0 ) Photo is the first one we made.
>
> I'm not sure if its the sunxi networking driver voodoo but it doesn't detect that the Ethernet has gone down  ( it reports  <6>PHY: sunxi_gmac-0:01 - Link is Down<c> )
> ifconfig reports that the link is still up and the route is still in my routing table after the cable has been unplugged..
>

If the cable getting unplugged is the primary failure mode, metrics should work...

The RUNNING flag should disappear in ifconfig of the interface is down..

Reply all
Reply to author
Forward
0 new messages