Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i want to konw my ip internet address 1

Status
Not open for further replies.

alonak

Programmer
Mar 4, 2003
8
0
0
IL
i'm working throw a router , and i what to know
the out internet address by vbscript.
now i'm checking it throw the web (whatismyip.com).
thanks Alon
 
Try:

Code:
<%
IPAddress = request.servervariables(&quot;REMOTE_ADDR&quot;) ' returns local address
response.write (&quot;IP of local: &quot; & IPAddress & &quot;<br>&quot;)
IPAddress = request.servervariables(&quot;LOCAL_ADDR&quot;)   ' returns web server
response.write (&quot;IP of server: &quot; & IPAddress & &quot;<br>&quot;)
%>

But I can't get it to work through a https connection - all I get is IP for my ISA server (?) - not my local address.
 
PGTurner:

Interesting. I'm surprised you get your local box's IP even on HTTP connections. Sounds like your ISA box isn't providing NAT to your desktop, and that you are only proxying HTTPS and not HTTP throught it.

Hmm, just looked at my proxy settings dialog on this Win2K box and I see that you can set HTTP and HTTPS differently. Wonder if you have a messed up situation there or if that is just your site's policy (proxy HTTPS but not HTTP) or what?


I think maybe that is what alonak is after. Not the local machine's actual IP, but the IP presented to the world by a NAT or proxy server.

Either he/she must do as PGTurner suggests (ask an outside server what the IP appears to be) or else write a script for the local desktop that can ask the NAT or proxy server what the &quot;outside&quot; IP address is.

This isn't rocket science, but it would be non-trivial. The script needs to know what it is talking to, how to do it, and how to request the info and interpret the results. All of it being variable depending on the actual proxy/NAT device and software. I'm not even sure that ISA would offer this info to a client.

My cable router here at home has a simple web-admin interface one could code against using an HTTP component. But the resulting script still wouldn't work on other NAT/proxies unless code was added for each different network device that one might want to interrogate.

For example I suppose the web-admin interface of my cable modem means I could ask it the same question about the IP assigned to my router's cable-side port.
 
You are probably reading it correctly. The http returns the vpn provided ipaddress to my ( home based ) PC. The https returns the isa address. I am not ( at least I don't think I am) proxying the http traffic.

I don't know what alonak is trying to do but my interest is driven by some terminal server issues.

I want something of the local machine preferably the IP address that is presented to the world. I have users that chew up all my Win-not-2k licenses for terminal services. I know they are valid users but would like to know where they are, whether a particular person is using it from the six different PCs at the library or whatever.

I haven't been too successful.
 
Code:
Set oHTML = CreateObject(&quot;MSXML2.XMLHTTP&quot;)
oHTML.Open &quot;GET&quot;, &quot;[URL unfurl="true"]http://whatismyip.com/index.cfm&quot;,[/URL] False
oHTML.Send
sText = Split(oHTML.ResponseText, &quot;TITLE>&quot;)
WScript.Echo Left(sText(1), Len(sText(1)) - 17)
Set oHTML = Nothing
WScript.Quit
Jon Hawkins
 
Looks good johnscott8.

I gave up because I couldn't figure out what IP address alonak was after.

If he/she is behind a home NAT router your script could be modifed to get the &quot;external&quot; IP from the router's web admin pages as well.
 
I have had a chance to test jonscott8's solution. It does operate but I get the visible-to-the-world IP address from my web server, rather than the visible-to-the-world address of my client.

It would seem the the web server is doing the querying, not the local client. Which I guess makes sense, since asp is server side.

So I guess my question probably belongs in another forum.
 
johnscott8's script was a client-side script, a WSH script to be precise.

It still isn't clear exactly who wants which computer to retrieve which IP address in this thread.
 
I fuddled with the above code and came up with this as of
Wednesday, May 18th, 2005.
The code references and parses the webpage searching for the point just before it gives us the external ip we want. Once found we isolate it and display it. This is my first ever attempt at .vbs scripting and I'm quite please I got it to work. The trick was realizing that the website changes over time so the above code no longer works.

Whatismyip.vbs

Set oHTML = CreateObject("MSXML2.XMLhttp")
oHTML.Open "GET", " False
oHTML.Send
sText = Split(oHTML.ResponseText, ">Your IP Is ")
WScript.Echo Left(sText(1), Len(sText(1)) - 1215)
Set oHTML = Nothing
WScript.Quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top