The devices behind a modem or an internet router will be assigned with private ip for communication within the internal network. When these devices needed to communicate to the outside world, the modem/router translate the private IP address to the public IP address which is called as NAT ( Network address translation )

To get information about our public IP, open any web browser and visit the page https://ifconfig.io/.

The same page also provide api to get the details.

Public IP using PowerShell

( Invoke-WebRequest -uri "https://ifconfig.io/ip" ).content 

Refer to https://ifconfig.io/ to get more information about the API

Hope you like this article and thank you for reading.