Logic Machine Forum
GET IP PUBLIC ADRESS - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: GET IP PUBLIC ADRESS (/showthread.php?tid=1859)



GET IP PUBLIC ADRESS - demeur - 24.01.2019

Hi every body, 

when you install a Logic Machine out from your office or ( your home for logic machine lover's  Wink )  and you haven't got any dns suscribe in order to get the IP public, it's important to know the logic machine's site IP public if you want to manage it trough the internet ( whith a nat of course one the HTTP socket ) 

this is my script for get ip public adress (then you can send it trough email )



---------------------------------------------------------------------------------------
local http = require("socket.http")
value = http.request('http://www.mon-ip.com/en/my-ip/')


if ( value ~= nil and string.match(value,'var Ip') ) then
  
  a = string.find(value,'var Ip')
  b = string.find(value,';',a)
  c = string.find(value,'\"',a)
  
  
  d = string.sub(value,c+1,b-2)
  log(' IP = ',d)
  if ( storage.get('IP PUBLIC') ~= d) then
    IP_CHANGED = true
  end
  storage.set('IP PUBLIC',d)
  
else
  --ERROR NO INTERNET OR www.mon-ip.com stop working
end
---------------------------------------------------------------------------------------

Best regard


RE: GET IP PUBLIC ADRESS - Daniel - 24.01.2019

Hi
Thanks for sharing, Here is another way
https://forum.logicmachine.net/showthread.php?tid=1148&pid=6836#pid6836
BR