Solved

Get Client's IP Address.

Posted on 2000-03-11
9
7,944 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
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 10

Expert Comment

by:kollegov
Comment Utility
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
Comment Utility

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

$ENV{'REMOTE_ADDR'};
0
 

Author Comment

by:soso071898
Comment Utility
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
 
LVL 10

Accepted Solution

by:
kollegov earned 200 total points
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Expert Comment

by:GlobalVillage
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Comment accepted as answer
0
 

Author Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now