Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

External ip address in Android programmatically

I have searched everywhere on how to get the external ip address with no avail. I am able to successfully get the local ip address.

In short what i want to do to get the same ip address as when I go on whatip.com or whatismyipaddress.com. However, I do not want to make any calls to the websites, is there a built in way to get this?

Also, I want the external ipaddress if the user is connected to wifi.

like image 480
thunderousNinja Avatar asked Aug 03 '11 19:08

thunderousNinja


People also ask

How do I find my external IP address on Android?

For Android The most common way to find it is to head to Settings>Network & Wi-Fi> Select the network you connected with then press Advance to know the information related to IP.

How do I find my external IP address on my phone?

Android. Select Settings from the application menu. Go to About Device > Status. Scroll down and look for the IP Address.

What is external IP address example?

External (Public) IP Address Also, any website that you visit will have access to this IP address. Your external IP address is 172.70. 38.150. Every website also has an IP address of its own, though you never need to know them.


2 Answers

However, I do not want to make any calls to the websites, is there a built in way to get this?

No. This is impossible on most pieces of hardware, including desktops and notebooks, let alone phones. Generally, you are behind some sort of NAT, which defines your "external ip address".

like image 138
CommonsWare Avatar answered Sep 28 '22 08:09

CommonsWare


IcanHazIP.com gives you a short and sweet response for the external IP.

However, using that URL on a large number of phones will inevitably yield the same IP for a few devices (for the reason that CommonsWare has already explained).

Idea: The data might be more meaningful if you collect the external IP combined with the local IP. So send a request to IcanHazIP.com followed by the following sample code for the Local IP: http://chandan-tech.blogspot.com/2010/12/finding-ip-address-of-your-android.html

By the way, I've worked on development devices with Modems that were activated by Sprint and their local IP's actually were external IP's

like image 37
Someone Somewhere Avatar answered Sep 28 '22 06:09

Someone Somewhere