[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7971
  • Last Modified:

Get Client's IP Address.

Hi,
Is there a script that can get me the client's IP address.
And if that client is behind a proxy or firewall can I get both the client's internal IP address as well as his proxy's Ip address?
0
soso071898
Asked:
soso071898
  • 3
  • 3
  • 2
  • +1
1 Solution
 
kollegovCommented:
You can't detect user IP with Javascript when MIE used as browser.  
MIE always return 127.0.0.1
(:Bill's understanding of security :)
Meanwhile it possible to do with my VMaxIPCatcher Java Applet. It have JavaScript callback of setIP(ip) javascript function, so you can define this function and it will be called and IP will be passed into this function.. You would find applet at my site
http://come.to/vmax 
follow links in menu..                 ->applets->misc->VMaxIpCatcher

This applet work for NN3+, MIE4+
and return client IP even if client is behind firewall..Sorry, I don't know the way to get clien't firewall/proxy IP address...

Virtual_Max
0
 
lambdaCommented:

Using CGI you can get the client (proxy) IP from environment variable:

$ENV{'REMOTE_ADDR'};
0
 
soso071898Author Commented:
Thanks Kollegov but I need to use GetIpAddress function on the clients side (not in CGI) in my application which I am developing for a client. I need a way to make this by myself or use a free non-licensed code. Is your class free for commercial use? Also The code posted at your page is not working on my PC which is behind a proxy. I expected to get at least the local IP address.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
kollegovCommented:
Quite strange that it didn't work for you. Do you mean that when you accessed
my page at
http://www.geocities.com/virtual_max/vmaxipcatcher.html
you didn't got your IP address?
May be you wasn't patient enough? Sometimes geocities is too slow, and applet loading can be a bit slow..

Can you tell details of browser you use?

Actually, doesn't matter that you are behind proxy, it must work.

As for license terms :)...
Any of my applets are absolutely free with KEY  "Free Version", but free versions expose link back to my site. In addition this applet with "free version" do not perform javascript callback.

I can build version of VMaxIPcatcher which wouldn't have the last limitation.  You can e-mail me virtual_max@geocities.com and I'll e-mail you package.
0
 
GlobalVillageCommented:
I'm entering into this kind of late, but will this do?

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin

if ((navigator.appVersion.indexOf("4.") != -1) && (navigator.appName.indexOf("Netscape") != -1)){
ip = "" + java.net.InetAddress.getLocalHost().getHostAddress();
document.write("Your IP address is " + ip);
}
else {
document.write("IP Address only shown in Netscape with Java enabled!");
}
//  End -->
</script>
0
 
GlobalVillageCommented:
But where are my manners.  You'll need IE code as well.

Try this one:

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin

if ((navigator.appVersion.indexOf("4.") != -1) && (navigator.appName.indexOf("Netscape") != -1)){
ip = "" + java.net.InetAddress.getLocalHost().getHostAddress();
alert("Your IP address is " + ip);
}
else {
if(navigator.javaEnabled() && (navigator.appName != "Microsoft Internet Explorer")) {
vartool=java.awt.Toolkit.getDefaultToolkit();
addr=java.net.InetAddress.getLocalHost();
host=addr.getHostName();
ip=addr.getHostAddress();
alert("Your host name is '" + host + "'\nYour IP address is " + ip);
   }
}
 
//  End -->
</script>



0
 
kollegovCommented:
Global Village, before posting code
it's a good manner to test it yourself...

1. MIE do not allow to call classes from java packages directly..
2. Among 2  branches of your code
one for Navigator
and other NOT for explorer :-)

Where is explorer branch????

Soso, you need to run applet via http:// protocol to get IP. It wouldn't detect IP in case it was started from local file

0
 
soso071898Author Commented:
Comment accepted as answer
0
 
soso071898Author Commented:
Thanks for all of you.
Kollegov's applet is working fine
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now