In a previous blog post, I described that I had set up a smart plug that pings a pre-arranged IP address, and if the ping fails, the smart plug will power-cycle our modem and main router in our office.
The world we live in is enriched because there are smart people around us (not only smart plugs!). One of those smart people is alert reader Manuel Fortin, who commented:
Very interesting, but I see a problem with the ping feature. What address will you use? If the address is unreachable for any reason that is unrelated to your modem and router, you will just end up with an endless loop of resets. Pinging an address within your network will not reset the system in case you lose internet access. Pinging an address outside of your network would completely disable your network if that address only, or a subset of the internet, cannot be accessed. It happens that servers, even from the most reputable companies, experience problems, or that problems make some part of the internet impossible to access.
Of course he is exactly right. It is the Goldilocks problem. Ping a host that is too close, and the ping result tells you nothing of interest. Ping a host that is too far away, and the ping result might get overwhelmed with noise from Internet connectivity failures that have nothing to do with any good reason for power-cycling of your own modem or router. It needs to be “just right”. So how to do it “just right”?
The answer that I offer to Mr. Fortin is to ping the “first hop in the traceroute”. The traceroute (Wikipedia article), shown above, is a good way to learn the IP address of the CMTS (Wikipedia article), which is the piece of equipment at the other end of the RF link for our cable Internet connection. Prompted by Mr. Fortin’s comment, I have performed the traceroute, learned the IP address of the CMTS, and configured our smart switch to ping that IP address instead of the far-away IP address that I had previously used.
For a customer using DSL rather than cable Internet, the “first hop” will give you the DSLAM (Wikipedia article) which is also, I think, “just right” for this purpose.
I think that I have now done what is “just right”. Thank you to Mr. Fortin.