Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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., 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?

share|improve this question
up vote 5 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
share|improve this answer
if you get a proxy ip address (IE, a wrong one) try – Journeyman Geek Apr 4 '10 at 2:40
The question specifically said "without having to visit some website". – David Schwartz Jan 7 '13 at 6:22

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

dig +short

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

share|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. – user26996 Apr 4 '10 at 17:10

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. 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 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

share|improve this answer

Add this to your ~/.bashrc file on Linux or ~/.bash_profile on Mac.

alias myip='wget -O - -q ; echo'

Then run

source ~/.bashrc


source ~/.bash_profile

Source will activate the changes you made to your bash file. It's only required once.

Now type 'myip' from command line, and you get the public IP address.

:# myip
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .