Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a command by which I can find my external IP of my router or my NAT\DSL Router, etc., eliminating the need to visit or similar.

share|improve this question
on windows that is –  Junaid Saeed Jul 21 '10 at 6:06

13 Answers 13

up vote 10 down vote accepted

There is no built-in command to do this. Part of the problem is that when you are connected to the internet through a router, your network hardware is not directly connected to the internet, so your system isn't specifically assigned an IP. It's possible you might even have multiple external IPs in some cases if you are behind a reverse proxy, as many corporate networks are set up. Your best bet might be to create a script which queries, or trying to find if one already exists.

(As a tip, is preferable to most other solutions, since it just returns your IP as plain text - no superfluous text, links, images or other garbage. It would be much easier to use in a custom script than most of the other IP-detection sites.)

share|improve this answer
They changed, unfortunately; the IP address is now returned as an image, making it pretty much useless for scripting. The website "" mentioned below does work. –  onnodb Nov 29 '12 at 13:53
Yandex is working, check the script posted below. –  Filipe YaBa Polido Dec 5 '13 at 15:42

grab your own copy of curlfrom and then just

$> curl ""

or use powershell:

$> $wc = new-object System.Net.WebClient
$> $wc.DownloadString("")

(disclaimer: was created by me)

share|improve this answer
hey! it says on the bottom of your site: © 2012 - 2015, a service of | powered by vim, golang and prettify. html5 and css21 -- can you tell me what did you use VIM for? –  IIIIIllllllllIlllllIIIIIIIIlll Apr 29 at 16:55
@Yuck: the code. –  akira Apr 29 at 18:40
llooks beautiful! which plugins did you use? –  IIIIIllllllllIlllllIIIIIIIIlll Apr 29 at 23:52
@Yuck: .. but this is not the right place to discuss such things. i'd suggest you visit that gist and then we delete these comments. –  akira Apr 30 at 9:24

You could use a DNS request instead of HTTP request to find out your public IP:

C:\> nslookup

It uses dns server to resolve the magical hostname to your ip address.

Unix version:

$ dig +short
share|improve this answer
Worked like a charm. –  B.K. Jun 29 '14 at 4:15
brilliant, works without installing anything too. –  ericosg Sep 7 at 11:54

Create a file named ip.vbs and copy the following into it:

Option Explicit
Dim http : Set http = CreateObject( "MSXML2.ServerXmlHttp" )
http.Open "GET", "", False
Wscript.Echo http.responseText   'or do whatever you want with it
Set http = Nothing

Execute using

C:\>cscript ip.vbs

As nhinkle noted, it's best to choose a site that only returns the IP and not HTML + ads, etc. like:

(source: formerly

share|improve this answer

I made this batch script to do that a few months ago:

@echo off

:: WhatIsMyIP.cmd - returns public IP address
:: requires: wget.exe

if [%1]==[-h] goto :HELP
if [%1]==[--help] goto :HELP
if [%1]==[/?] goto :HELP

wget -q -O %temp%\MyIP
for /f "delims= " %%G in (%temp%\myip) do set PublicIP=%%G & del %temp%\MyIP
echo. & echo Your public IP address is %PublicIP% & echo.
if [%1]==[--clip] echo %PublicIP% | clip
goto :EOF

echo. & echo Usage: whatismyip [--clip] & echo.
goto :EOF


It gives you the option to put the IP address in the clipboard and it sets an environmental variable - %PublicIP%.


Now, I just do this instead:



curl | clip get the current public IP address into the clipboard.

You need cURL.

share|improve this answer
The script from paradroid worked fine but whatsmyip moved the web page to If you change to this, it works perfect. –  Puffen Apr 19 '12 at 6:52

Try this:
Doesn't need any kind of external software installed.

@set @script=0 /*
  @echo off
    set @script=
    cscript //nologo //e:jscript "%~dpnx0"
  exit /b

with (new ActiveXObject('Microsoft.XMLHTTP')) {
   open('GET', '', false);

share|improve this answer

Without third party programs is hard on Windows as Telnet isn't supplied by default, but, if it is there (XP) or turned on (Windows Vista and above), simply type:

telnet 80

the screen will flash, and you will just get a cursor... Next type:


In capital letters... you will then see the headers, followed by your ip (and sorry I blurred it, just showing where it would be!):

enter image description here

Other answers here obviously work, but, I'm trying to keep to the question on something that can be used on any windows, without third party programs!

For Windows Vista and above, you can install telnet easily (and safely) through Programs and features, or use the following command:

pkgmgr /iu:”TelnetClient”
share|improve this answer
That (and most of the answers!) does assume that the source website picks up your ip address accurately - some types of proxies mess this up. I was scraping my ip address off my router cause of this. Interestingly, in these cases, a website that uses a non standard port may work fine. –  Journeyman Geek Jan 15 '14 at 1:21
Not working with, but tested working with –  Sopalajo de Arrierez Dec 7 '14 at 13:04

With Powershell 3.0 (Windows 7 default is 2.0) you can use Invoke-WebRequest

For IPv4:

$tmp =Invoke-WebRequest -URI

For IPv6:

$tmp =Invoke-WebRequest -URI

This will give you a variable to work with if you have something specific you want to do with it. I'm actually using this to build a script to upload my router's dynamic IP periodically, have another machine test communication to it at regular intervals, and then update DNS with the latest IP if it has changed so I can access my gear from anywhere by using a name instead of having to constantly chase down the IP.

And of course - as the sites change or their outputs change you'll want to update this accordingly. :)

share|improve this answer

You can use it supports some internal commands that come with windows by default.

nslookup .
share|improve this answer

Here is what I figured out, it's possible to use in-built command to get public IP address but you do have access to internet




share|improve this answer
Good catch! Although won’t work for me and the other one doesn’t do IPv6 properly. :) –  Daniel B Mar 22 at 15:32

This works nicely, I use it mostly with psexec when inspecting client computer connections.

share|improve this answer

Are you able to log into your router? Should find the info there, like on a Status page.

Using a Mozilla browser & NoScript? NoScript Options | Advanced | ABE -> WAN IP.

share|improve this answer

I also had same problem and because i didn't find any solution I wrote purpose .net command line application. It is free, you can download it here. Application uses same approach as is shown in these answers but because it is designed for this purpose is much more reliable (it can use more more external web pages at once and so). Source is visible using reflection.

share|improve this answer
A download link is not an answer and is likely to attract downvotes. –  fixer1234 Sep 20 at 1:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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