net.publicip readonly property
The net.publicip property gets the current public IPv4 address as a string
. A valid Internet connection must be available, or returns false
otherwise.
Example
local net = require "net"
print("Public IPv4 IP : "..net.publicip)