I have two internet connections via LAN Cable. I am from India, so they are not reliable. If one internet stops working, I want to automatically switch to another internet connection.
I wrote this script to check, If Internet is working or not:
try:
request = requests.get("http://www.google.co.in", timeout=5)
except (requests.ConnectionError, requests.Timeout) as exception:
try:
request = requests.get("http://www.amazon.com", timeout=5)
except (requests.ConnectionError, requests.Timeout) as exception:
print("Internet not working, switching internet.....")
If there is no ping from google & amazon, I need to switch internet.
My connection name is "Wired connection 1" and "Wired connection 2".
Edit: If someone has a solution in any other language or using software, please let me know.