How to always know the ip address on a public network
Moderators: grovkillen, Stuntteam, TD-er
How to always know the ip address on a public network
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?
Re: How to always know the ip address on a public network
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.
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)
Re: How to always know the ip address on a public network
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
Re: How to always know the ip address on a public network
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)
Re: How to always know the ip address on a public network
Will this send the local or the public IP address?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
Re: How to always know the ip address on a public network
The ESP has only 1 IP address, so it will be the local IP.
/Ton (PayPal.me)
Re: How to always know the ip address on a public network
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.
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.
Who is online
Users browsing this forum: No registered users and 144 guests