Solved

Get Client's IP Address.

Posted on 2000-03-11
9
7,958 Views
Last Modified: 2011-08-18
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
Comment
Question by:soso071898
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 10

Expert Comment

by:kollegov
ID: 2609369
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
 
LVL 1

Expert Comment

by:lambda
ID: 2611118

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

$ENV{'REMOTE_ADDR'};
0
 

Author Comment

by:soso071898
ID: 2614657
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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 10

Accepted Solution

by:
kollegov earned 200 total points
ID: 2615993
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
 

Expert Comment

by:GlobalVillage
ID: 2859558
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
 

Expert Comment

by:GlobalVillage
ID: 2859573
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
 
LVL 10

Expert Comment

by:kollegov
ID: 2862277
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
 

Author Comment

by:soso071898
ID: 2941891
Comment accepted as answer
0
 

Author Comment

by:soso071898
ID: 2941892
Thanks for all of you.
Kollegov's applet is working fine
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question