Force a Web Request to be run locally?


#1

I want to be able to make a call to an external URL that returns my External (WAN) IP address, but my web requests are always run externally, returning a webcore IP address, not mine.

I understand that Webcore determines if it is an internal address range and if not, runs it in the cloud, not locally.

Is there any way I can get the web request to be executed locally?


#2

I don’t think it is possible without using some kind of middle-man…

For example, you can have your piston send a command to your local server. (Raspberry Pi, Android running Tasker, etc) Then that server can make the external call, and send the results back to a webCoRE piston.


#3

Yeah, I was hoping to avoid that.

I have some local cameras that that handled well, locally, but had hoped I could make a call to an external URL from within that same piston and get my external IP address…

Is there any other way to get my hub’s to report it’s external IP address?


#4

Well, with most home networks, the ST hub and router have the same external IP.

If yours is set up the same, then you can probably make a web request from a piston directly to your routers config page. I do something similar to identify when my phones are home (connected) or away (disconnected).

Here is three posts of mine showing how I did it.
It should be very similar to snag your IP address.


#5

I took a few minutes and whipped up a piston that tells me when my External IP address changes, and what the new IP is.

A few caveats:

  • It only checks the current IP when the piston runs (currently set every 6 hrs)
  • Each Router’s Config page is different, so your code will not match mine
  • The IF block is 100% optional, but I like the way it informs me upon changes

Lines 41-48 could probably be reduced into one crazy line, but I prefer my code easy to read & edit, so I will often program in stages…


Here is a sample output on my Dashboard:

temp


If you decide to go this route, you will probably want to reference the Wiki/Functions page. It explains the indexOf(), mid(), and left() commands that I used above.

Also, when stripping down the extra text, I recommend using “Log to console” after each step because it will show the hidden characters. (for example, <td> is invisible, but it was there until I removed it)


Notification if IP address changes
[RELEASE] Value Tiles - DTH for displaying webCoRE variables / Stats in a 'Thing'
Checking NORDVPN through Make a Web Request
#6

For this, I would store your External IP in a global variable, and then reference the global variable from your camera piston. (just keep in mind that it will not be live data)


#7

Great. I used this approach and made myself a piston that gets my WAN IP address and allows me to update my old camera vendor’s DDNS directory, so passed the first hurdle.
Now my attempt to also update my DNS-o-Matic or OpenDNS DDNS entry fails, when trying to update it with this new WAN IP. Apparently the piston doing external DDNS update needs to originate from my local network…
So it seems I still need to somehow get the piston to execute locally to make this work.
Thanks anyway.


#8

Sorry to hear that. From a security standpoint, it does make sense though…
(at least you now have access to your External IP)

For what it’s worth, I think a $38 Raspberry Pi should be in all of our homes. There are so many ways to tie it in with webCoRE / SmartHomes / Web server / Media storing & streaming / Database storage etc.