I have two different internet connections on my house (from two different ISPs). And I use a TP-Link ER605 Multi-Wan router to manage both connections and deliver a single internet connection to my wired home network.
This router has a single job: When the main connection goes down, it redirects all the traffic to the backup connection, and I just don't notice any outage at all when it happens.
The thing is: I would like to get some kind of notification when my main connection is not working so I can check if something is wrong on my end, and if this situation persists for some time, I can call my ISP to ask for technical support.
I can use "traceroute" (on Linux) or "tracert" (on Windows) to trace the route between a computer on my network and the Google Public DNS (8.8.8.8
) to determine which Internet connection I'm using.
tracert -h 2 -4 -d 8.8.8.8
traceroute -4 -n -m 2 8.8.8.8
If the second hop is 192.168.15.1
, it means that my router is using the main connection to get to the Internet, but if the IP address is 192.168.0.1
, it means that the main connection is offline and router is redirecting the traffic over the backup connection. (On this specific case, it's on the third hop on the linux example, because it's a VM on another NAT network).
The problem is: I don't know how to automate that verification, and get some kind of notification depending on which connection is in use. It could be an e-mail like "Main connection is down" and "Main connection restored".
I have my Laptop running Windows 10 running 24/7 and I also have a Raspberry Pi (with Raspian Linux) that I could just leave connected all the time for this specific task. So both Windows and Linux solutions would work for me.
tracert -d -h 2 -4 8.8.8.8
(on Windows) ortraceroute -4 -n -m 2 8.8.8.8
(on Linux). It'll return the IP address of the modem used to reach the internet. If it's 192.168.15.1 I know the main link is in use, but if it's 192.168.0.1, I know the main connection is down and the backup connection is in use. I just don't know how to automate this verifications and get notifications for that.