The internet account at the Farm doesn’t have a static IP address, so it is difficult to remotely access it, say by ssh or scp. I solved this by writing a script that polls a responder, such as icanhazip.com and then sends me an email whenever the IP address changes.

It is a bit of a hack but it works, and has gotten me out of trouble when my fancy DDNS system failed to restart after a power outage & reboot.

However, the external IP address is stored in the router, so why go out to the internet when all we really need to do is ask the router? It turns out that this is not so easy to do, or should I say, there were no clear results that I could find.

But I was tantalised by the prospect of being able to interrogate the router to discover and log a range of performance and quality measures, such as upload and download speeds (‘Link rate’) in Netgear speak, line attenuation and noise margin. Look at all the lovely info in the ‘statistics’ window, below:

Router statistics screenshot

Eventually, I found a solution. Here it is:

curl -u username:password http:/192.168.0.1/RST_statistics.htm > curl-ftw.txt

Where:

  • ‘username’ and ‘password’ are what you use to login to your router
  • ‘192.168.0.1’ is the IP address of your router
  • the name of the page matches the URL of the page you wish to access. In this case you can see it displayed in the screenshot

This example just writes the html to a text file, but all you have to do now is to parse the file and extract the data you are interested in.

I have not taken advantage of this yet but when I do, I’ll put the code onto github.

I will document the ‘icanhazip’ script a bit later, with a link to its code on github.