Full Version: Discovering Wan Ip
bah
Was wondering if anyone had a cmdline tool which would
show the target pcs WAN ip

now doing ipconfig /all shows only the lan ip which is of no use if u want to
target the box from outside the lan

yes we can remote to pc and load internet explorer and go to whatismyip.com
or someother website. Thats no the soln I am looking for

Other alternative is to login to the box on the lan and ping a remote host from the box and check the firewall logs for the incomming ip. This works sometimes but not
all the time

so can anyone give me some other ideas or perhaps theirs a cmd line tool somewhere that can discover the wan ip

bonarez
if you do a tracert google.com you can see the adres of the router, whitch narrows it down to about 253 adresses (2-254)

so you'll see
1st line > ip of router
2nd line ip of isp's router <frist 3 octets of ip>.1

the firtst 3 octets are the same as the wan's first 3
withdraw
Just ping something then look at your arp table

CODE

C:\Documents and Settings\Administrator>ping google.com

Pinging google.com [216.239.37.99] with 32 bytes of data:

Reply from 216.239.37.99: bytes=32 time=105ms TTL=232
Reply from 216.239.37.99: bytes=32 time=105ms TTL=232
Reply from 216.239.37.99: bytes=32 time=101ms TTL=232
Reply from 216.239.37.99: bytes=32 time=104ms TTL=232

Ping statistics for 216.239.37.99:
   Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
   Minimum = 101ms, Maximum = 105ms, Average = 103ms

C:\Documents and Settings\Administrator>arp -a

Interface: XXX.XXX.XXX.XXX --- 0x2
 Internet Address      Physical Address      Type
 XXX.XXX.XXX.XXX          00-00-89-12-14-e4     dynamic

C:\Documents and Settings\Administrator>


*EDIT*
You might have to clear you arp table cuz there might be too many entries in there

CODE

arp -d *


**EDIT**
err yeah nm that only works if ur not behind a router
bah
Tracert isnt a bad idea, but on the box it fails

tracing route to google.com

.... request times out

I have seen a perl script to check ip via website

http://cwashington.netreach.net/depo/view....ScriptType=perl

how to run this under winblows ? ... excuse my ignorance

well I found this little app
http://www.indigostar.com/perl2exe.htm
perl2exe

but trying to compile it failed anyone any ideas?



Converting 'wanip.pls -v -gui' to wanip.exe
Warning: Can't locate Win32/Internet.pm
at wanip.pls line 30
@INC =

----------------------------------------------------------------------------------

well I figured my mistake I forgot to install
Perl2Exe for Windows requires an installation of Perl on your machine
hehe

------
anyway it successfully compiles
perl2exe wanip.pls -v -gui
Converting 'wanip.pls -v -gui' to wanip.exe

then when we run the prog

C:\>wanip

WAN IP Address:
C:\>

doesnt print ip address anyone any ideas or can some one else code the same script in C

----------------
well messing about with it it appears that the extracting of the ip in the script
from the webpage is messed

##############################################################################
# Extract WAN IP Address
#

$intSTART = index($strFILE, $strStartWAN) + length($strStartWAN);
$intEND = index($strFILE, $strEndWAN);
$intWANSize = $intEND - $intSTART;
$strWANIP = substr($strFILE, $intSTART, $intWANSize);

##############################################################################
print "\n";
print "WAN IP Address:";
print $strWANIP;

by simply adding to the end
print $strFILE;

it works printing the webpage like so
wanip
WAN IP Address:<html><head><title>Current IP Check</title></head><body>Current IP Address: xx.xx.xx.xx</body></html>

anyway it works I compiled it for winblows and its attached to this post

if anyone care to enlighten me how to clean the output I can recompile it


daguilar01
thx for fixing and compiling it bah, gonna chekc it out, smile.gif
basepart
try the CmdNET.exe, it's a command line tool.
if you can't find it anywhere, pm me your email and I'll send it to you.


+----------------------------------------------+
| CmdNET v1.0 σ 2000 JPSoft DK |
| support@jpsoft.dk - http://www.jpsoft.dk |
| |
| CmdNET is FREEWARE and used at your own risk |
+----------------------------------------------+

Usage: CmdNET [options]

-f[filename] redirect output to 'filename'
-l resolve local ip address
-p resolve public/WAN ip address
-m resolve MAC address of NIC

You can substitute the '-' with '/' if you like it better

EXAMPLES:
---------
CmdNET /l show local ip address
CmdNET /p show public/WAN ip address
CmdNET /fTest.txt /m redirect output (MAC address) to file Test.txt

NOTE: Return codes, 0 = successfull and 1 = unsuccessfull
n3mesis
Google should eventually time out, thats just the way its servers are configured, but the first couple of address' should appear, showing the IP of your router and the ISP's router unless they are also configured not to respond to it.
I've seen the first one time out but not the second or third, ISP usually don't do that
basepart
Well, this subject is kind of old but till today I hadn't an easy solution to find my WAN IP from a command line or a batch file since CmdNET.exe doesn't work anymore.
This is my idea, but since I don't have permission to post my own threads yet, I'll add it here smile.gif

To find my wan IP I use netcat (nc.exe), a text replacer tool, and a batch file. Here how it goes...
I use 1st the "nc.exe" to connect to http://checkip.dyndns.org and get the html code which include my WAN IP,
and then I use the text replacer tool to clean up the output and keep pure the IP in the file "wanip.txt".

Copy the lines below to a text file and name it as "wanip.bat"

CODE
@echo off
echo GET HTTP/1.1>get
echo.>>get
nc.exe -vv checkip.dyndns.org 80<get>tmpip.txt
replace.exe "<html><head><title>Current IP Check</title></head><body>Current IP Address: " "" tmpip.txt /I
replace.exe "</body></html>" "" tmpip.txt /I
FOR /F "tokens=* skip=7" %%I IN (tmpip.txt) DO echo %%I>wanip.txt
del tmpip.txt
type wanip.txt


the text replacer tool can be found here: http://bobby.mydis.org/download/rep32302.zip

hope it's usefull for someone
agamemnon
ActivePerl runs on windows.
basepart
QUOTE (agamemnon @ Aug 26 2004, 09:49 PM)
ActivePerl runs on windows.

Yes agamemnon, "ActivePerl runs on windows" but it needs installation, and is much bigger than these two small tools.
Of course you can use perl2exe to compile your code, but in case that the web page layout change,
it's easyer to do some changes in a batch file than recompile with perl2exe.
Anyway, this is just an extra option, and at my opinion is more simple and flexible wink.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.

 
Invision Power Board © 2001-2005 Invision Power Services, Inc.