How to get External IP address in ionic

Hi,

I am using cordova-network–Interface plugin.

Here is my code.

networkinterface.getWiFiIPAddress((ip) => {
       console.log("IP");
      console.log(ip);
    });

It’s return local IP address.

I need to get external IP address.

Kindly advice me,

Thanks

1 Like

Actually all the network interface commands are working with local IP address.
If you want to catch the valid IP address (internet routable) you better use an online IP information service.

Example:
http://www.ip-api.com/json

3 Likes

actually, looks like now is possible with the same plugin.

  this.networkInterface.getCarrierIPAddress()
    .then(address => console.info(`IP: ${address.ip}, Subnet: ${address.subnet}`))
    .catch(error => console.error(`Unable to get IP: ${error}`));