maxhugen
maxhugen

Reputation: 1944

Get IPv4 Address From Modem or External Website

I'm trying out Google Sheets communicating with my home MySQL db.

To get a connection, Sheets must use the external IPv4 address, but as the Telstra (AUS) NBN service I have is DHCP, I need to check that my IP address hasn't changed, otherwise I have to update it in my script.

Does anyone know of a way to get the IP from a modem, rather than having to pay for a dedicated IP, or checking every time?

[Edit] As an alternative, I'm also trying to get my current IP from an external website, using INSERTHTML().

https://ifconfig.me/ip: seemed a good idea, but it's simple html is in neither a table or list, so that won't work: <body><pre> [my IP] <\pre><\body>. https://www.whatismyip.com/: got data using {"list",3} as params for the function, but it seems to take ~1 sec to return the IP, so the site just sends back Not Yet Detected to the function.

[Edit 2] Well, that was a useless exercise, since if I call a function from Sheets itself or GAS (UrlFetchApp.fetch), I get a Google IP. Du-oh!

Still searching...

Upvotes: 0

Views: 82

Answers (1)

Alex L
Alex L

Reputation: 157

You could obtain a free DNS from a site such as DuckDNS, and create a script (or use the one which they provide) to run in any machine in your local network so that your domain gets updated every time your IP changes. Therefore, in your Google Sheets connection you would set the domain instead of the dynamic IP.

Upvotes: 1

Related Questions