1

My home Internet connection (via Ethernet) is unreliable - when it's working I can get 90 Mbps, but around 50% of the time from 12pm to 10pm it is not working. When the home Internet is not working, I turn on the personal hotspot on my phone and switch to it on my laptop. After a while, I check if the Internet is back up by pinging through the Ethernet interface.

ping -I enp4s0 google.com

If the Ethernet connection is working, I switch back to it.

However, data is expensive, so I don't want to use it if the Ethernet connection is working. Having to manually check if it's working and switching back-and-forth is a slow process.

I am asking to see if there's a tool that will automatically check if the Internet is working via one Interface, and route traffic through that interface. But if it is not working, then route traffic through a backup interface.

I am using Ubuntu 18.04, but am looking for a generic Linux-based solution.

Note that I am not asking how to switch to Ethernet when it is plugged in. The Ethernet cable is always plugged in but the Internet may not be reachable from it.

2
  • What's the port name for your hotspot? Can't finish the script without that.
    – K7AAY
    Commented Apr 10, 2020 at 20:58
  • 1
    @K7AAY I connect to the hotspot through WiFi so it'll be through the wlp5s0 interface.
    – dayuloli
    Commented Apr 11, 2020 at 11:37

1 Answer 1

0

No canned tool known. Therefore, suggest you write a script, to have cron run a job to ping out enp4s0 to 8.8.4.4 and 1.0.0.1 (just in case Google's taking a break). (I suggest that to eliminate the script getting fooled by a DNS problem.)

If you can connect, switch to enp4s0 if you're not already using it.

If the answer include the word unreachable or times out, make sure you're using Mister Hotspot.

2
  • 1
    That's the logic I am looking for, but is there a tool that does this? Or I'd have to write my own script?
    – dayuloli
    Commented Apr 11, 2020 at 11:41
  • See updated answer w/ clarification, above.
    – K7AAY
    Commented Apr 12, 2020 at 1:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .