Batch File - Finding the IP address

January 25, 2006 at 14:57:32
Specs: win xp pro, p4 3.2 gh
I was looking for an alternative way to find the IP address of a computer that is for sure the internet IP address,

I know about IPCONFIG |FIND "IP" method, but it is not a sure way as it gets last IP address in the list not necessarily the the internet IP address,

and it should connect to internet to find the ip address,
eg. nslookup can show the current ip address but it needs a connection to internet.

Does anybody know an alternative way or a 3rd party program that can do that?

thanx in advance


See More: Batch File - Finding the IP address

Report •

January 25, 2006 at 20:18:42
it should NOT connect to internet to find the IP address,

I am writing a batch file that finds the ip address and I don't want others (who don't have access to the source)to think it is sending out their information.


Report •

January 26, 2006 at 01:55:51 will give you your external IP address

Report •

January 26, 2006 at 17:33:20
that leads to nowhere!!!!!
I am looking for a batch file solution to implnat in my scripts!!!!!
even if there is a 3rd party executable that finds the internet ip address without connecting to the internet itself, it will do it for me.

any ideas?


Report •

Related Solutions

January 26, 2006 at 19:30:14

This is how I used to find the IP address:

FOR /F "tokens=2 delims=:" %%a in (%temp%\TEMPIP.txt) do set IP=%%a
del %temp%\TEMPIP.txt
set IP=%IP:~1%
echo %IP% >%temp%\ip.txt
echo The current IP address is "%IP%"


I was able to exclude local IP addresses – – –

IPCONFIG |FIND "IP" | find /v "" | find /v ": 192.168." | find /v ": 10." | find /v ": 172.16." | find /v ": 172.17." | find /v ": 172.18." | find /v ": 172.19." | find /v ": 172.20." | find /v ": 172.21." | find /v ": 172.22." | find /v ": 172.23." | find /v ": 172.24." | find /v ": 172.25." | find /v ": 172.26." | find /v ": 172.27." | find /v ": 172.28." | find /v ": 172.29." | find /v ": 172.30." | find /v ": 172.31."> %temp%\TEMPIP.txt
FOR /F "tokens=2 delims=:" %%a in (%temp%\TEMPIP.txt) do set IP=%%a
del %temp%\TEMPIP.txt
if "%IP%"=="" (echo You are currently not connected to Internet and you do not have an IP address.) else (set IP=%IP:~1%)
echo %IP% >%temp%\ip.txt
if not "%IP%"=="" echo The new IP Address is "%IP%".

First of all does anybody know an easier way for excluding – rang?

and the 2nd problem is, to is also reserved for DHCP failures and it is not a valid IP address,
Can anybody help me exclude this rang also?

Report •

January 28, 2006 at 07:40:03
Parsing text with a batch file is not an easy task.

Your first post indicates that you're open to alternative methods. If you want I can provide you with a Perl script. Since I'm safe behind a broadband router (i.e. I don't have my computer directly exposed with a public IP), I can't use my ipconfig output do the proper testing. If you post your output of ipconfig, both with and without the public IP, I'll be able to do the proper testing/debugging.

Report •

January 29, 2006 at 14:26:58
If you decide you want to look into using a Perl script, here's the documentation on the module that can extract the info from ipconfig. You may not understand the syntax, but the documentation should give you a good idea of what it can do.

Report •

Ask Question