How to always know the ip address on a public network

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
djakov
Normal user
Posts: 16
Joined: 03 Nov 2020, 21:25

How to always know the ip address on a public network

#1 Post by djakov » 14 Dec 2021, 13:02

Hi, i am interested if there is a way to always know what is the IP address of a device connected to a public(portable sim card router) wifi. First on my mind it comes to send requests to a server on 5-10 seconds to a server to store the current IP address of the device, considering it is dynamic, and whenever i want to access the device to send a command, i will look up in the DB to see what is the device current IP address. Maybe my thinking is not the best, maybe there is another easier solution for this. Any help?

User avatar
Ath
Normal user
Posts: 3513
Joined: 10 Jun 2018, 12:06
Location: NL

Re: How to always know the ip address on a public network

#2 Post by Ath » 14 Dec 2021, 13:33

Software only solutions:
Sending data like that requires that destination to be available without requiring some certificate check, like via http, but not via https, but for external (cloud) resources that will most likely be a challenge.
If you are using an email relay, you can send the IP address after successful connection to WiFi ('on WiFi#Connected do' event).
Similar can be done for an MQTT server.
Another possibility is to give the unit a fixed IP, then it shouldn't be an issue to connect to the unit, but that probably won't work if you need roaming between WiFi networks.

Hardware based solution:
You can install some type of display (can be OLed, TFT or 7 segment, if not already available) and present the IP there, usually the last octet is enough, so sending %ip4% could be sufficient.
/Ton (PayPal.me)

djakov
Normal user
Posts: 16
Joined: 03 Nov 2020, 21:25

Re: How to always know the ip address on a public network

#3 Post by djakov » 14 Dec 2021, 13:43

Isn't there a way to send a http request? All i need to send requests in 5 seconds like http://someURL?currnet_ip=12.34.56.78. This solves everything for me

User avatar
Ath
Normal user
Posts: 3513
Joined: 10 Jun 2018, 12:06
Location: NL

Re: How to always know the ip address on a public network

#4 Post by Ath » 14 Dec 2021, 14:26

Sure, you should use the proper event for that, in Rules:

Code: Select all

on WiFi#Connected do
  SendToHTTP,<ip-or-domain-name>,<portnr>,<rest-of-the-url-using-variables-like-%ip%>
endon
/Ton (PayPal.me)

djakov
Normal user
Posts: 16
Joined: 03 Nov 2020, 21:25

Re: How to always know the ip address on a public network

#5 Post by djakov » 17 Dec 2021, 16:33

Ath wrote: 14 Dec 2021, 14:26 Sure, you should use the proper event for that, in Rules:

Code: Select all

on WiFi#Connected do
  SendToHTTP,<ip-or-domain-name>,<portnr>,<rest-of-the-url-using-variables-like-%ip%>
endon
Will this send the local or the public IP address?

User avatar
Ath
Normal user
Posts: 3513
Joined: 10 Jun 2018, 12:06
Location: NL

Re: How to always know the ip address on a public network

#6 Post by Ath » 17 Dec 2021, 18:55

The ESP has only 1 IP address, so it will be the local IP.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8749
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: How to always know the ip address on a public network

#7 Post by TD-er » 17 Dec 2021, 23:53

It is impossible to know your "public" IP without some online service or querying your router (which is proprietary, not a standard query)
ESPEasy does for sure not support some lookup service to know the "public IP" as you can see on sites like whatismyip.com thus it does not know what the public IP is.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 146 guests