0

I'm using Raspberry Pi 3B. I've ethernet eth0 and a 4G module ppp0 connected. Priority connection is eth0. I can detect whether ethernet cable is connected to the raspberry pi or not using commands. But Can I check whether the internet is there or not without ping command?

I want such thing which can monitor all of my interfaces at the same time. If internet is available on eth0, the main interface will be eth0. When the internet is down on eth0, the connection should switch ppp0. As soon as the internet is available again on eth0, it should switch back to eth0.

How can I achieve this? I don't want to check this thing using ping command again and again after a fixed interval. Plz help.

theashwanisingla
  • 269
  • 1
  • 11

1 Answers1

2

What you want to have is a classical failover scenario. Fortunately Linux has a professional solution for it with bonding. With it you can combine two (or more) interfaces where you can configure what should be the primary interface and switch over to the reserved interface if the primary fails and switch back if the primary is available again. This all is done automatically without the need to monitor interfaces and switch them with scripts. How to do it with a Raspberry Pi you can look at Howto migrate from networking to systemd-networkd with dynamic failover.

Ingo
  • 42,961
  • 20
  • 87
  • 207