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

How do I get my external IP address from the Windows and Linux command line?
On Windows, ipconfig shows an internal network IP address, but it does not show the external one.

share|improve this question
Are you in a managed environment such as a school or office? – cutrightjm Apr 3 '12 at 5:11
Nor should they know the external network address, the gateway out of your network will know this. You may be able to get your external IP by querying the gateway, but that all depends upon how it has been configured. – Ardesco Apr 3 '12 at 9:59
up vote 17 down vote accepted

Neither Windows or Linux is aware of its external IP address, so they cannot natively let you know. So you have to use an external service to find out what the IP address is.

Under linux, you can use curl and one of the many services that let you know what your address is:

$ curl

There are equivilent options for Windows, such as installing curl. Note that curl itself is not determining your IP address, it is simply asking an external website what IP address you appear to be coming from.

However, the best way to do this is to use a dynamic DNS (DDNS) service like Here you can dynamically register your external IP address into DNS. So instead of using an IP address, you can use a domain address, such as

Most domestic routers support updating DDNS automatically when the external address changes, and if not, there are clients for Windows and linux (ddclient).

share|improve this answer
Actually, Windows does if you are using a router that supports UPnP and don't have something broken like double-NAT. – David Schwartz Apr 3 '12 at 6:10
You can also 1.) look up your external IP by logging in to your router; 2.) google "IP"; 3.) as well as the whatismyip automation link, you can use domain tools' API which gives a lot of other info. – Lèse majesté Apr 3 '12 at 6:17
@DavidSchwartz Where can you view this in windows? – Paul Apr 3 '12 at 7:04
@Paul: You'd need to write a program to do it or find one that does. The functions are part of the UPnP API. Basically, it asks the router. – David Schwartz Apr 3 '12 at 7:10

A Google search for What's my IP address works quite well.

Your public IP address is ##.###.###.178

You can also get some information about your network to give you a good idea about what is going on. Using tools like netstat, traceroute, ssh or telnet you can figure out how you are getting on the puplic network of the Internet.

There are the public and private IP address. If you know which is the private IP address ranges then you can guess which IP address you are using on the outside network. As soon as a traceroute ends using private IP address ranges it has moved on the public network.

Private network (Wikipedia)

I would start by finding my default gateway.

In Linux:

netstat -r

In Windows:

netstat /r

Which should show you something like

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface      *        U         0 0          0 eth0      *        U         0 0          0 wlan0   *        U         0 0          0 virbr0
link-local      *          U         0 0          0 eth0
default         UG        0 0          0 eth0

Notice the default at the bottom, that should be your last step before going out into the public world.

Now a traceroute to Google's DNS server address,, to see what path you take to the outside world.





Which should give you some thing like this

traceroute to (, 30 hops max, 60 byte packets
 1 (  0.564 ms  0.882 ms  0.848 ms
 2  ##.###.###.177 (##.###.###.177)  12.239 ms  13.040 ms  13.859 ms

The step after my default route was onto our outside network.

The Google search differed from the traceroute but only by the one digit. This is because you would need an IP address in the same range as your ISP to be able to communicate with them. So our router has an IP address one down from our external IP address that is used by our ISP to route traffic to the rest of the world.

Your public IP address is ##.###.###.178

What might help here is to know that one device the router has all three IP addresses. The private one, (default route), and the internal one provided buy our ISP ##.###.###.178 and the external one ##.###.###.177 our ISP uses to connect to the Internet. So if I know how to remotely connect to the router using Telnet/ssh I can use query the router directly to get this information using the command line.

Different routers and ISP's have different ways of managing this. Most home DSL modems are quite easy to get ssh into as you have the password and login information but if the ISP has put in a router at your office, they probably won't give you access to their router.

share|improve this answer

You can use the lynx tool to get the external ip.

lynx --dump

share|improve this answer
They also offer lite version, only returns the ip: – stefgosselin Apr 3 '12 at 5:19
Thanks for your information. – Mughil Apr 3 '12 at 5:28

Your machine doesn't know your external address. You have to use an external service and fetch the results (e.g.,

You can use any command line HTTP clients as wget or curl:

$ wget -q -O -
<html><head><title>Current IP Check</title></head><body>Current IP Address:</body></html>

wget is available on both Windows and GNU/Linux

share|improve this answer is a site you can visit in the browser to get nearly all the information you need. You can also use curl on that page with the shown variables, to get just that piece of specific information. The data is returned in a JSON formatted string, which makes scripting with it pretty easy. Check the bottom of the page for more examples.




share|improve this answer

You must log in to answer this question.

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