Policy-based routing with ppp0 and eth0

Running debian on a pi3.

I can switch between eth0 and ppp0 to reach the internet but only one interface can be active at a time. Of course this is because the Linux OS manages the default gateway and routing tables when an interface is taken down. Such as:

    ifconfig eth0 down
    pon e303

This prevents me from checking the cable modem on eth0. I’d like to have both physical interfaces up but when the cable modem internet becomes unresponsive, I’d like to send out http data (json) over the ppp0 interface. I’d also like to periodically ping over the ppp0 interface to verify it’s working as well.

My lack of network routing, etc. is beyond my ability to even search for the answers! I’m guessing I need to modify routing tables and determine how to force IP out over a specific interface from python code.

Any suggestions welcome.

Hi Steve,

This is a case we’ve planned for with the Python SDK. hologram.network.connect() will route traffic over the cell interface so you can also keep the eth0 interface up. Here’s a link to a tutorial:
https://hologram.io/docs/tutorials/send-msg-python-sdk-cellular/#connect-to-cellular-network

Hope this helps and let us know if you have any questions!

-Ryan

Ok. That worked and it’s easy to send an SMS message. Now what I want to do is send json to another of my servers like this:
conn = httplib.HTTPSConnection(“mysslserver.org:443”)
conn.request(“POST”, “/api/data.json”, myEncodedData, {“Content-type”:“application/x-www-form-urlencoded”})

It’s not quite clear how to make this jump.

Never mind. That would skip the cloud services which does add value. I’ve found the webhook can easily accomplish my task and my preliminary tests indicate there’s minimal latency.

This does open a security issue as I must put authentication data on your server for the webhook. How do you suggest I secure that data?

http://lartc.org/howto/lartc.rpdb.html#LARTC.RPDB.SIMPLE

Lartc.org is an old site, but it did tell me how to do policy based routing. Your needs will require scripting to switch route wherever the cable goes down, but it is possible!