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.

  • You have provided NO information about your setup, so if you do get answers these are likely to be speculative. It is possible that setting priorities may solve your REAL problem, rather than what you actually asked.
    – Milliways
    Commented Nov 26, 2019 at 8:49
  • Try installing ifplugd. That used to be in Raspbian and would switch to a WiFi network when the ethernet cable was disconnected. It's a right PITA and I'm glad it's gone in Buster. But, if it still works, it does what you want.
    – Dougie
    Commented Nov 26, 2019 at 8:56
  • Hi, priorities are absolutely right as per my needs. Ethernet is having the top priority. But I wanna know how to check for the internet on Ethernet when my 4G module is up. And I couldn't get what more information should I provide. I'm sorry. Commented Nov 26, 2019 at 8:57
  • Hi Dougie, my problem is a bit different. I don't want to know whether the cable is disconnected or not. I wanna know whether internet is working or not. Commented Nov 26, 2019 at 8:58
  • @Dougie About ifplugd: doesn't work with default dhcpcd but I have Make ifplugd available again since Raspbian Stretch.
    – Ingo
    Commented Nov 26, 2019 at 10:42

1 Answer 1


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.

  • Hi Ingo, This is what I actually wanted. But, my bad, there is a line in bold fonts that It will not work with Raspbian Stretch! :( Commented Nov 26, 2019 at 10:50
  • @theashwanisingla Please read the next line in that tutorial: Here you will find the last tested revision for Raspbian Stretch Lite. Sorry, that isn't bold ;-)
    – Ingo
    Commented Nov 26, 2019 at 11:14
  • Hehehe.. thanks... I read it but ignored coz it was for lite. Thanks. I'll try this. Commented Nov 26, 2019 at 11:16
  • @theashwanisingla It also works with the full versions of Raspbian. There is no difference between the network setup. The only disadvantage may be that network settings are not supported by the GUI.
    – Ingo
    Commented Nov 26, 2019 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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