I'm looking for a way to get my IP address using the command prompt in Linux. I know when you type "ifconfig" you can get your local IP address (i.e. 192.168.0.103), but I'm looking for my IP address that I get from my ISP. How can I get this from Linux without having to visit some website?

link|improve this question

feedback

3 Answers

up vote 4 down vote accepted

If your machine is assigned a local IP address, it may not know your public-facing address. You can query a server not on your local network to discover your public-facing address.

$ curl whatismyip.org
link|improve this answer
1  
if you get a proxy ip address (IE, a wrong one) try checkip.dyndns.com:8245 – Journeyman Geek Apr 4 '10 at 2:40
feedback

You can use one of the several services that tell you your own address:

dig +short myip.opendns.com @resolver1.opendns.com
curl corz.org/ip
curl ip.uostas.net

(I still haven't found one that supports IPv6.)

link|improve this answer
+1, that's really useful for an external-facing ip... pity about the lack of IPv6 services but you'd need an IPv6 connection to the net and most ISPs/broadband routers don't seem to support it. – Ninefingers Apr 4 '10 at 17:10
feedback

If your computer is on e.g. a corporate LAN with an address-translating firewall there is unfortunately no information on your computer about the externally visible address. For all your computer knows it has a local IP (e.g. 192.168.0.103) that can be used to connect to any host on the Internet. The address-translating firewall is completely transparent from your computer's point of view.

The only way is to use an external "observer" such as whatismyip.org to help. If you don't like having to access it through a full web browser curl is an alterantive as pointed out by Samuel K

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.